How do I convert blocks in Simulink library to C/C++ code in Simulink 7.4 (R2009b)?

4 visualizaciones (últimos 30 días)
I have a custom Simulink library that I would like to generate code for. How can I go about generating a C/C++ function for each subsystem in my custom library?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 4 de Dic. de 2012
You can generate C/C++ code out of a Simulink library by placing each library block into a new Simulink model, wrapping each library block into an Atomic Subsystem and generating code for the new model. Specifically, you can follow these steps:
1) Drag and drop all library blocks into a new Simulink model
2) Wrap each library block in a subsystem
3) Set the subsystem as Atomic (Right click -> Subsystem Parameters -> Treat as an Atomic Unit)
4) Set the system to generate code as a reusable function (Right click -> Subsystem Parameters -> 'Code Generation' tab -> set 'Function packaging' to 'Reusable function'
5) Generate code using Real-Time Workshop
The resulting generated code will then contain separate source files for each library block that you have included in the Simulink model. You can chose to use the source files directly in your C/C++ application, or optionally compile the source files into a static or shared library using a third-party compiler.

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2009b

Community Treasure Hunt

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

Start Hunting!

Translated by