You use block dialog box parameter settings to specify Simscape™ run-time parameters. However, Simscape block dialog box parameter settings do not show run-time settings unless you set the default behavior to do so using MATLAB® preferences. For an example that shows you how to set the default behavior to show run-time parameter settings for run-time configurable Simscape parameters, see Show Simscape Run-Time Parameter Settings.
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:
Set the default to tunable
Set the default 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.
The PM DC Motor example model contains a DC Voltage block. You parameterize the block by specifying the Constant voltage for the source. The voltage is supported as a Simscape run-time parameter. To specify Constant voltage as a run-time configurable parameter:
To open model, at the MATLAB command prompt, enter:
ssc_dcmotor
From the model window, access the parameter settings for the DC Voltage block.
To specify Constant voltage as
a Simscape run-time parameter, for the run-time setting, select Run-time
.
Specify the Constant voltage parameter
value as the variable vDC
.
Assign a numeric the value to the variable in the MATLAB workspace:
vDC = 5;
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, click the Fast restart
icon on the Simulink Editor toolbar.
To simulate the model, click the Run button on the Simulink Editor toolbar.
Open the Motor RPM scope block. Autoscale to see the results better.
Assign a different value to the variable that represents voltage:
vDC = 1.5;
Simulate the model.
Open the Motor RPM scope block.
The results reflect the change in value for the run-time parameter.