How can I generate separate cpp files for each subsystem in my simulinkk model using embedded coder?
1 view (last 30 days)
Show older comments
I want to introduce modularity to my simulink model and hence want each simulink block to be translated to a cpp file using Embedded Coder.What I did was this: 1. Created a simlink model with n blocks 2. Wrapped each significant simulink block to a subsystem 3. Set the Subsystem parameters 'treat as atomic unit' and 'Function Reuse" 4. Built the model.
I was expecting n soucefiles for each of my subsystem.But I got only one relevant soucefile with the name of my simulink model. Is there something I am missing? your help will be appreciated.
0 Comments
Answers (1)
Juan Reyes
on 16 Jun 2016
Edited: Juan Reyes
on 16 Jun 2016
Use TLC functionalities
You may need to add a customized TLC. If you are using an ERT target try going to: Model Configuration Parameters -> Code Generation -> Templates.
In Custom Templates browse your customized file "MyTlc.tlc" which you should have created in your working directory.
Try writing this inside "MyTlc.tlc":
%%%%MyTLC.tlc
%assign name = "MyDesiredSourceFile"
%assign cFile = LibCreateSourceFile("Source", "Custom", "name")
%openfile contentBuf
.....The content you want in foo.c**....
You can acces all your model parameters using the model.rtw file
%closefile contentBuf
%<LibSetSourceFileSection(cFile,"Functions",contentBuf)>
More info in:
0 Comments
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!