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. Simscape run-time parameters are run-time configurable. You cannot change the value of a run-time configurable parameter during simulation. 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 compile-time configurable by default. To make a Simscape block parameter run-time configurable, you specify it as such.

  • Simulink tunable parameters are tunable-by-field. You can change a tunable parameter simply by changing the numeric value using the block dialog box parameter setting. Simscape run-time parameters are tunable-by-variable. To change the value of a Simscape run-time parameter, you:

    1. Specify a variable for the parameter in the block dialog box setting.

    2. Use input tools, such as the command prompt, callbacks, scripts, or MAT-files, to assign a value for the variable in the MATLAB® workspace.

    3. Use input tools to change the value for the variable.

  • For code generation, you specify the Default parameter behavior as Tunable or Inlined. 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 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 to Inlined, 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

DevelopmentNormalSimulationStatus is stoppedNot Applicable (NA)YesYes
DevelopmentNormalSimulationStatus is runningNANoYes
Development or Target

Normal, Accelerator, Rapid Accelerator, SIL, PIL, or External

SimulationStatus is stoppedNAYesYes
Development or TargetNormal, Accelerator, Rapid Accelerator, SIL, PIL, or ExternalSimulationStatus is runningNANoYes
TargetNormal, SIL, PIL, or ExternalSimulationStatus is stoppedSetup-functionYesYes
TargetNormal, SIL, PIL, or ExternalSimulationStatus is running
  • Step-function for a Simulink global variable

  • External code for a Simulink parameter object

NoYes

Between normal mode simulations, as long as your changes do not affect the structure of the model, you can forgo recompiling by using fast restart when you change Simscape run-time and Simulink tunable parameters.

Related Topics