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":
%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
More info in:

Community Treasure Hunt

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

Start Hunting!

Translated by