Main Content

About Simscape Run-Time Parameters

Simscape™ run-time parameters are MATLAB® variables or Simulink.Parameter objects that are run-time configurable. By default, run-time configurable parameters are noninlined during code generation. Simscape run-time parameters allow you to skip recompilling the model when you change parameter values. You can change parameter values:

  • Between fast-restart, iterative simulations on a development computer

  • In referenced models on a development computer

  • In the generated code in a rapid simulation (RSim) or on real-time target hardware

For more information on using Simscape run-time parameters for these types of simulation, see Improve Parameter-Sweeping Efficiency Using Simscape Run-Time Parameters.

By default, all Simscape block parameters are compile-time parameters. You can only change the value of compile-time parameters in the plant model on your development computer.

Enabling Run-Time Configurability

To view the Simscape Run-time option, set your preferences to show runtime settings. For more information, see Show Simscape Run-Time Parameter Settings.

Simscape supports run-time configurability for most parameters that require a numerical value input. To determine if you can specify a particular parameter as a Simscape run-time parameter, review the settings for the parameter in the block dialog box. If run-time parameters are enabled and a parameter is run-time configurable, you will see a dialogue box set to the default setting, Compile-time. You can change this to Run-time for the parameters that you want to be run-time configurable. You can change this setting at any time before you generate code from your Simscape model.

To specify a Simscape block parameter as run-time configurable, change the run-time configuration setting, which appears next to the dialog box for the parameter, from Compile-time to Run-time. The figure shows a run-time configuration setting for the Constant voltage parameter of the Permanent Magnet DC Motor in the ssc_dcmotor Simscape example. The parameter entry is the variable V1, whose value you specify in the MATLAB workspace. You can also specify run-time parameter values numerically in the dialog box.

For an example that shows how to specify and change Simscape run-time parameters on development and target computers, see Specify and Change a Simscape Run-Time Parameter and Change Parameter Values on Target Hardware.

While Simscape run-time parameters can make iterative simulation more efficient, using them can decrease the efficiency of code that you generate. Code that contains compile-time or inlined run-time parameters is more computationally efficient because it does not have to store or retrieve parameter values. If you set the default parameter behavior for code generation to inlined, the generated code algorithm inlines the numeric values of all block parameters as constants.

For information that can help you decide when to inline Simscape run-time parameters, see Decrease Computational Cost by Inlining Simscape Run-Time Parameters. To learn how to inline Simscape run-time parameters, see Manage Simscape Run-Time Parameters.

Simscape run-time parameters not the same as Simulink® tunable parameters. For information on comparisons between the two types of parameters, see How Simscape Run-Time Parameters and Simulink Tunable Parameters Differ.

Run-Time Configurability for Block-Level Variable Initialization Target Values

Some Simscape blocks have Variables settings that allow you to set a target value for block-level variable initialization. For more information, see Initializing Block Variables for Model Simulation and Set Priority and Initial Target for Block Variables.

The variables included in the Variables settings are run-time configurable by default. You can tune a block-level variable-initialization target value between simulation runs if you specify the target value using a variable that you save to the MATLAB workspace.

Related Topics