-1

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?

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62

1 Answers1

0

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.

ErikP
  • 161
  • 1
  • 8