Specify parameters to be PrivateGlobals in Simulink Coder

1 回表示 (過去 30 日間)
Shamoil
Shamoil 2023 年 11 月 1 日
回答済み: Altaïr 2025 年 2 月 3 日
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 Center および File ExchangeAudio 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