I am working on ball and plate in Matlab Simulink. I have a ball tracking Matlab file. How can I run it in Simulink? I want position data from ball tracking Matlab file. I tried s function from user defined functions but my code is not working because of videoinput error. What should I do?
-
1Show your efforts. What have you done so far? Where exactly are you getting the error? Maybe post some code so that people here can help you. – Devraj Gadhavi Apr 27 '17 at 04:03
-
i added the tracking code so sory for first entry – KralBey Apr 30 '17 at 14:55
1 Answers
Code intended for simulink (embedded) coder must be of such nature that code can be generated from it. This means that only a subset of Matlab functions are supported. Typically code that is to be supported for code generation should have the "pragma"
%#codegen
inside the function definition.
What to do depends on your goal:
A) If you want to generate code from your model:
You need to rewrite the function in code that is not tagged as invalid for %#codegen. (Some work included - sorry...)
B) If you just want to run in simulink:
Use the coder.extrinsic mechanism. This is just a directive that you put inside the matlab function (block) code and tell simulink that you want to use a matlab function that is outside of the codegen specification. After you have done that you can call your normal function (put it in a function m-file). However, if you try to generate code; that specific function call will be ignored. The rest of the code will try to execute on best effort.
Final note; if you are developing (command prompt) functions that you might someday want to call or include in matlab function blocks in simulink, you should throw in the %#codegen pragma so that it helps you avoid functions that cannot be used in code generation.

- 161
- 1
- 8