Specify parameters to be PrivateGlobals in Simulink Coder

1 次查看(过去 30 天)
How do you specify specific parameters to be PrivateGlobals in Simulink Coder?
There is an option to set all block outputs as global variables in Code Generation>Optimisation>Opt Levels but it does not mention how we can only specify a select few block outputs as globals.
Thanks

回答(1 个)

Altaïr
Altaïr 2025-2-3
The Code Mappings pane is a useful tool for adjusting the storage class of Simulink signals. If it isn't visible, it can be accessed by selecting Code Interface > Individual Element Code Mappings from the C CODE tab in Simulink Coder.
To make specific block outputs global in the generated code, follow these steps:
1. Go to the Signals/States tab in the Code Mappings pane.
2. Select the output signal whose storage class needs modification and click the Add selected signals to code mappings, icon.
3. Change the storage class of the signal to ExportedGlobal.
4. Click the icon on the right and edit the identifier name to the desired value, which will be the signal's name in the generated code.
After these steps, click Build to generate the code. The global signal can be viewed in the generated code using the report.
For more information on Code Mappings, please refer to this page:

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by