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
3 views (last 30 days)
Show older comments
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)
Answers (1)
Hitesh
on 26 Nov 2024
Edited: Hitesh
on 26 Nov 2024
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1814108/image.png)
For more information regarding the "Code Mapping", kindly refer to the below MATLAB documentation:
0 Comments
See Also
Categories
Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!