Codegen for M-S-Function
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Anshuman
le 15 Mai 2023
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!
0 commentaires
Voir également
Catégories
En savoir plus sur Simulink Coder dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!