Follow up question, how do you define the relationship between the inport/outport numbering in Stateflow and the ordering in the function parameters, in the generated code?
How to generate code with named inports/outports
2 ビュー (過去 30 日間)
古いコメントを表示
I have a project in stateflow that I am generating code for using embedded coder, 2022b.
Some of the ports are named in the generated code, as per the model, some have generic names, arg_Outport, arg_Outport1, etc
I cannot work out what to change/menu to open/option to generate the code with the ports renamed.
Can anyone point me in the right direction?
I have inherited the project, I've used Matlab a fair bit in the past but stateflow and the coder are relatively new so not sure if I'm doing something daft or theres a bug? (I suspect the former)
回答 (1 件)
Hitesh
2024 年 11 月 26 日
編集済み: Hitesh
2024 年 11 月 26 日
You need to use "Code Mapping -Component Interface" option. For changing the generic names of Inport/Outport blocks in Code Generation's code, kindly follow the below steps:
- Open the "Code Mapping - Component Interface" from the bottom left corner of the Simulink window.
- Navigate to the "Inports" tab.
- You will see a list of all the Inport variables you have created.
- For the variables you wish to rename, set their storage class to "ExportedGlobal."
- Use the Edit option to rename the variables as desired for the code generation output.
- Switch to the "Outports" tab.
- Repeat steps 3 to 5 for the Outport variables.
I have attached a sample reference model.

For more information regarding the "Code Mapping", kindly refer to the below MATLAB documentation:
0 件のコメント
参考
カテゴリ
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!