Codegen for M-S-Function

2 次查看(过去 30 天)
Nima Mohseni
Nima Mohseni 2023-3-6
回答: Anshuman 2023-5-15
Hello,
I have a very complex M-S-Function block that uses classes and I would like to use it for codegen of a simulink model.
It will not be possible to write a reimplementation of the code as a tlc file without significant effort and loss of functionality.
Is it possible to do this?
Thank You

回答(1 个)

Anshuman
Anshuman 2023-5-15
Hi Nima,
It may be possible to generate C code from your Simulink model that includes your M-S-Function block using the Simulink Coder's code generation technology. However, there are several requirements that your M-S-Function block and associated classes must meet in order for this to work.
Firstly, the classes used in your M-S-Function block must be defined using MATLAB classes that are supported by Simulink Coder's code generation. Specifically, only a subset of MATLAB classes is supported, and not all classes can be used in code generation.
Secondly, any MATLAB code that is used in your M-S-Function block must be compatible with code generation. In practical terms, this means that the MATLAB code used in your M-S-Function block should not include any constructs or functions that are not compatible with code generation, such as certain built-in functions, unsupported toolboxes, or MEX files.
Finally, your M-S-Function block and associated classes should adhere to certain design guidelines for code generation. For example, you should avoid using dynamic memory allocation, avoid using global variables, and avoid using recursive function calls.
If you are able to meet these requirements, you can generate C code from your Simulink model using the Simulink Coder. You can go through the documentation if you need any help in generating C code from a simulink model.
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by