Specify and Change a Simscape Run-Time Parameter
If you want to generate code, you may need to change the default inlining behavior. This example shows how you can specify and change a Simscape™ run-time parameter once you have completed this step.
Prerequisites
Set the Default Parameter Behavior for Code Generation
Simscape run-time parameters depend on the default parameter behavior setting for code generation. To enable run-time configurability for a Simscape run-time parameter so that you can change its value without recompiling your model, you can:
Leave the default as
Tunable.Set the default to
Inline, and override the default behavior for the parameter with the value that you want to change.
For information on setting and overriding the default behavior for Simscape run-time parameters, see Manage Simscape Run-Time Parameters.
Specify a Parameter as Run-Time Configurable
The Permanent Magnet DC Motor example model contains a DC Voltage block. You parameterize the block by specifying the Constant voltage. The voltage is a Simscape run-time configurable parameter. To specify Constant voltage as a run-time configurable parameter:
To open the model, at the MATLAB® command prompt, enter:
openExample('simscape/PermanentMagnetDCMotorExample')Assign a numeric value to the
vDCvariable in the MATLAB workspace:vDC = 5;
Double-click the DC Voltage block to edit the parameters.
In the Configurability drop-down box for Constant voltage, select
Run-time.Specify the Constant voltage parameter value as the variable
vDC.

Change a Simscape Run-Time Parameter Using Fast Restart
To see how altering the value of a run-time configurable parameter can affect simulation results, change the value of the Constant voltage parameter between iterative fast-start simulations.
To enable fast restart, navigate to the Simulate section under the Simulation tab and click the Fast restart icon
. To simulate the model, click Run.
Open the Scope block called Motor RPM. Select Tools > Axes Scaling > Automatically Scale Axes Limitsto see the results better.

Assign a different value to the variable that represents voltage:
vDC = 1.5;
Simulate the model.
Open the Scope block.

The results reflect the change in value for the run-time parameter.
See Also
Topics
- About Simscape Run-Time Parameters
- Manage Simscape Run-Time Parameters
- Change Parameter Values on Target Hardware
- Accelerate, Refine, and Test Hybrid Dynamic System on Host Computer by Using RSim System Target File (Simulink Coder)
- How Acceleration Modes Work
- Get Started with Fast Restart
- How Simscape Run-Time Parameters and Simulink Tunable Parameters Differ