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

16 views (last 30 days)
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?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Dec 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.

More Answers (0)

Categories

Find more on Schedule Model Components in Help Center and File Exchange

Tags

Products


Release

R2009b

Community Treasure Hunt

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

Start Hunting!