Initialize Values to Inports in Embedded Coder
4 ビュー (過去 30 日間)
古いコメントを表示
Hello all,
I am trying to initialize my Simulink model's inports with some variables. Currently I have done the same using the Root Inport Mapper and used a .mat file along with it to initialize my inports. The values are being initialized when I run the model although they do not show up in the model_init function in the generated C code of the model.
Can anyone tell me how to initialize values to inports that show up in the generated C code using Embedded Coder?
0 件のコメント
回答 (1 件)
Anudeep Kumar
2025 年 4 月 1 日
Hello Atif,
I've experienced a similar situation, and I found that Code Mappings provided an effective solution. In Simulink, Code Mappings are integral to the code generation process, allowing you to specify how model elements are represented in the generated code. This feature is especially beneficial when using Embedded Coder to produce high-quality C/C++ code. I recommend reviewing the Code Mapping documentation and exploring some examples to better understand the workflow based on your model's requirements.
Code Mapping Documentation:
How to choose Data Configuration Approach: This page will help you answer various questions like what data elements to use, where to store the data, how to configure data to meet code generation objectives.
I hope these documentations help!
4 件のコメント
Anudeep Kumar
2025 年 4 月 11 日
編集済み: Anudeep Kumar
2025 年 4 月 11 日
I wanted to clarify our previous discussion regarding the use of root-level inports to map a MAT file to inports. I realize there was a misunderstanding on my part, as I have worked on just Code Mapping, which differs from your specific use case.
In my search for a solution, I discovered an example that demonstrates how to initialize root-level inports in the manner you require. I'm currently exploring how they set default values for these inports. Meanwhile, I've included a link to the relevant documentation. You might find it helpful to open the model and experiment with it yourself.

I have also attached a screenshot of model and the model itself.
参考
カテゴリ
Help Center および File Exchange で Deployment, Integration, and Supported Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!