Why Simscape variables are hard-coded in the generated code?

I am generating code for a physical network that includes a 'Constant Volume Chamber (G)'. I need to modify the initial pressure externally, but I cannot find an option to switch the configuration from 'Compile-time' to 'Run-time'. As a result, the exported C++ code has the initial pressure value hardcoded based on the current variable value in the Workspace.
Is there a way to configure the initial pressure at 'Run-time'?
If yes, could you please provide guidance on how to achieve this?

 採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 7 月 14 日

0 投票

The variables listed in the "Variables" settings are automatically configured as "Run-time" tunable if they are associated with a variable in the MATLAB Workspace. This is why there is no option to explicitly configure them to "Run-time" from "Compile-time".
As an example, you can adjust the initial pressure of the "Constant Volume Chamber (G)" by assigning it to a variable (such as the "InitialPressure," as shown in the screenshot below), which is specified in the Base Workspace:
 
Furthermore, it is essential to ensure that the "Default parameter behavior" under Configuration Parameters > Code Generation > Optimization is configured as "Tunable" before proceeding with code generation. This way, the Simscape variables can be modified at runtime. 
 
For additional information on this topic, you can consult the documentation page below:

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeRun-Time Parameters についてさらに検索

製品

リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by