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 recompiling 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

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 property inspector. If a parameter is run-time configurable, you will see a property inspector 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 Configurability setting, which appears in the block property inspector underneath the parameter name, from Compile-time to Run-time. The figure shows setting run-time configuration for the Constant voltage parameter of a DC Voltage Source block.

You can specify run-time parameter values numerically in the property inspector. You can also specify the parameter value by entering a name of a variable in the MATLAB workspace, and then tune the parameter by changing the value of the workspace variable. 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 Initial Targets 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 Initial Targets 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