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
4 次查看(过去 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!