matlabcode-generationsimulinksimulink-library

Disable SIMULINK Code Generation or call MATLAB functions with functions/Variables not supported by code generation


I have a complex MATLAB model consisting of several subfunctions that I need to integrate into a SIMULINK model. However, the MATLAB model uses tables and a lot of functions and operations which are not supported in the code generation of SIMULINK. Rebuilding the model in SIMULINK is not a suitable solution due to the model complexity.

Is there a way to disable code generation for MATLAB blocks or to call the MATLAB-Function in anyother way? I would like to run the model exclusively in the MATLAB environment.

Thank you very much in advance!

  1. I tried to use the Interpreted MATLAB Function Block, but it does not support multiple inputs and outputs.

  2. I tried to use the wrapper function mentioned in this threat, but i couldn't get it to work: https://de.mathworks.com/matlabcentral/answers/74770-is-there-any-way-to-disable-code-generation-in-simulink Does somebody know the right syntax to wrap a self-written MATLAB function with call of subfunctions? Other users are only wrapping a matlab function insinde the function of the MATLAB Block: How to turn off code generation in Simulink? (function is not supported for standalone code generation)

  3. Are the Level-2 MATLAB S-Function Blocks capable to call the model if the functions are all contained in one .m file?


Solution

  • Use coder.extrinsic to declare the function as "external". There are a few limitations regarding the use of the output, see https://nl.mathworks.com/help/simulink/slref/coder.extrinsic.html?searchHighlight=coder.extrinsic&s_tid=srchtitle_support_results_1_coder.extrinsic