MATLAB Answers

How can I specify the name of a header file containing a structure generated with Embedded Coder?

3 ビュー (過去 30 日間)
Brandon
Brandon 2014 年 12 月 9 日
編集済み: Juan Reyes 2016 年 6 月 16 日
The Simulink model I'm generating code from uses data from a Matlab structure called sample_times that is saved in the workspace. When I generate the code, the structure is included as a header file with a randomly generated name. Is there a way I can specify the name of this header file to be "struct_sample_times"?

回答 (1 件)

Juan Reyes
Juan Reyes 2016 年 6 月 16 日
編集済み: Juan Reyes 2016 年 6 月 16 日
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 = "struct_sample_times"
%assign hFile = LibCreateSourceFile("Header", "Custom", "%<name>")
%openfile contentBuf
.....The content you want in foo.h....
You can acces all your model parameters using the model.rtw file
%closefile contentBuf
%<LibSetSourceFileSection(hFile,"Functions",contentBuf)>
More info in:
Hope it works!

Community Treasure Hunt

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

Start Hunting!

Translated by