How can I generate separate cpp files for each subsystem in my simulinkk model using embedded coder?

1 次查看(过去 30 天)
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.

回答(1 个)

Juan Reyes
Juan Reyes 2016-6-16
编辑:Juan Reyes 2016-6-16
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:

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by