After you create a Simulink® model, you can enter configuration parameters for the model. These parameters control many properties of the model for simulation and code generation.
A configuration set is a named set of values for model parameters, such as solver type
and simulation start or stop time. Every Simulink model is created with a default configuration set, called
Configuration
, that initially specifies default values for the
model parameters. You can then create additional configuration sets and associate them
with the model. For more information about Simulink configuration, see Manage Configuration Sets for a Model.
The easiest way to specify configuration parameters for a Simulink Desktop Real-Time™ model is to assign the default Simulink Desktop Real-Time configuration set programmatically, as described in Specify a Default Configuration Set. You can also set parameters manually, as described in Enter Configuration Parameters Manually.
After you create a Simulink model, you can use the sldrtconfigset
function to specify a
default Simulink
Desktop Real-Time configuration set for the model. Usually, using sldrtconfigset
provides the
configuration parameter values that the model requires.
The following procedure uses the model sldrtex_model
. To open
this model, in the MATLAB Command Window, type:
open_system(docpath(fullfile(docroot, 'toolbox', 'sldrt', 'examples', 'sldrtex_model')))
It assumes that you have already loaded that model (see Create a Simulink Model).
If you have not already saved the model, on the Simulation tab, click Save > Save as. In the File name text box, enter a file name for your Simulink model and click Save. For example, type:
sldrtex_model
The Simulink software saves your model in the file
sldrtex_model
.
In the MATLAB® Command Window, type:
sldrtconfigset('sldrtex_model')
The default Simulink
Desktop Real-Time configuration set, SimulinkDesktopRealTime
,
is now active for the sldrtex_model
model.
Save the model.
For a description of how to build your Simulink Desktop Real-Time application, see Create a Real-Time Application.
To revert to the default configuration set, Configuration, or other configuration set you have for the model, use Model Explorer. For a description of how to use Model Explorer, see the Simulink documentation.
Your model uses a Simulink
Desktop Real-Time configuration set when you change the System target
file value to a Simulink
Desktop Real-Time one, such as sldrt.tlc
or
sldrtert.tlc
. The software creates the Simulink
Desktop Real-Time configuration set only if one does not exist.
The configuration parameters give information to Simulink software for running a simulation.
This procedure uses the model sldrtex_model
. To open this
model, in the MATLAB Command Window, type:
open_system(docpath(fullfile(docroot, 'toolbox', 'sldrt', 'examples', 'sldrtex_model')))
It assumes that you have already loaded that model.
On the Desktop Real-Time tab, click Hardware Settings. In the Configuration Parameters dialog box, click the Solver tab.
In the
Start
time field, enter 0.0
. In the
Stop time field, enter the amount of time you want
your model to run. For example, enter 10.0
seconds.
From the Type list, select
Fixed-step
. Simulink
Coder™ does not support variable step solvers.
From the Solver list, select a
solver. For example, select the general-purpose solver ode5
(Dormand-Prince)
.
Under Additional options, in the
Fixed step size field, enter a sample time. For
example, enter 0.001
seconds for a sample rate of
1000
samples/second.
Leave the parameter Treat each discrete rate as a separate task cleared. (For models with blocks that have different sample times, select this parameter.)
Click OK.
You enter or change scope parameters to specify the x-axis and y-axis in a Scope window. Other properties include the number of graphs in one Scope window and the sample time for models with discrete blocks.
After you add a Scope block to your Simulink model, you can enter the scope parameters for signal tracing:
In the Simulink Editor, double-click the Scope block.
On the toolbar, click the Parameters
button .
Click the Main tab. In the
Sample time text box, enter
-1
, which indicates that this block inherits its
value from its parent model. If you have discrete blocks in your model,
enter the Fixed step size value that you entered in the
Configuration Parameters dialog box.
Click the Time tab. In the
Time span box, enter 1
.
Click the Display tab. In the
Y-min and Y-max text boxes,
enter the range for the y-axis in the Scope window. For
example, enter -2
and
2
.
Click OK.