How Simscape Run-Time Parameters and Simulink Tunable Parameters Differ
Simscape™ run-time parameters and Simulink® tunable parameters both allow you to change the values of parameters on your development or target computer without model recompilation. However, they differ in these important ways:
You can change the value of a Simulink tunable parameter while a simulation is running, and it will impact the currently running simulation. Simscape run-time parameters are run-time configurable. You can only change the value of a run-time configurable parameter when a simulation is stopped.
Simulink tunable parameters are tunable by default. Simscape block parameters are only compile-time configurable by default. To make a Simscape block parameter run-time configurable, you must specify it as such.
For code generation, you specify Default parameter behavior as
Tunable
orInlined
. You cannot modify inlined parameters in generated code because the compiler specifies them as constants. You can change the values of tunable parameters in generated code because the compiler specifies them as modifiable global variables or structure fields.If you set the Default parameter behavior to
Tunable
, the compiler specifies all Simscape run-time parameters and Simulink tunable parameters as modifiable entities in the generated code. However, if you set the default behavior toInlined
, the compiler inlines only the Simscape run-time parameters. The Simulink tunable parameters are still generated as modifiable entities in the code. To change the value of a particular Simscape run-time parameter in the generated code when the default behavior is inlined, you declare that parameter as an exception to inlining.
The table shows the state, mode, and code section in which you can change a run-time parameter or run-time configurable parameter.
Machine | Simulink Simulation Mode | Simulation Status | Section of Generated Code That You Modify | Simscape Run-Time Parameter Is Modifiable | Simulink Tunable Parameter Is Modifiable |
---|---|---|---|---|---|
Development | Normal | Stopped | Not Applicable | Yes | Yes |
Development | Normal | Running | Not Applicable | No | Yes |
Development or Target | Normal, Accelerator, Rapid Accelerator, SIL, PIL, or External | Stopped | Not Applicable | Yes | Yes |
Development or Target | Normal, Accelerator, Rapid Accelerator, SIL, PIL, or External | Running | Not Applicable | No | Yes |
Target | Normal, SIL, PIL, or External | Stopped | Setup-Function | Yes | Yes |
Target | Normal, SIL, PIL, or External | Running |
| No | Yes |
Between normal mode simulations, as long as your changes do not affect the structure of the model, you can avoid recompiling by using fast restart when you change Simscape run-time and Simulink tunable parameters.
Related Topics
- Change Parameter Values on Target Hardware
- Tune and Experiment with Block Parameter Values
- Specify and Change a Simscape Run-Time Parameter
- Code Regeneration in Accelerated Models
- About Simscape Run-Time Parameters
- Manage Simscape Run-Time Parameters
- Decrease Computational Cost by Inlining Simscape Run-Time Parameters