Configure a Model for金宝appDesktop Real-Time
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, calledConfiguration
, 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, seeManage Configuration Sets for a Model.
The easiest way to specify configuration parameters for aSimulink Desktop Real-Time™model is to assign the defaultSimulink Desktop Real-Timeconfiguration set programmatically, as described inSpecify a Default Configuration Set. You can also set parameters manually, as described inEnter Configuration Parameters Manually.
Specify a Default Configuration Set
After you create a Simulink model, you can use thesldrtconfigset
function to specify a defaultSimulink Desktop Real-Timeconfiguration set for the model. Usually, usingsldrtconfigset
provides the configuration parameter values that the model requires.
The following procedure uses the modelsldrtex_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 (seeCreate a Simulink Model).
If you have not already saved the model, on theSimulationtab, clickSave>Save as. In theFile nametext box, enter a file name for your Simulink model and clickSave. 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 defaultSimulink Desktop Real-Timeconfiguration set,
SimulinkDesktopRealTime
, is now active for thesldrtex_model
model.Save the model.
For a description of how to build yourSimulink Desktop Real-Timeapplication, seeCreate 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 aSimulink Desktop Real-Timeconfiguration set when you change theSystem target filevalue to aSimulink Desktop Real-Timeone, such assldrt.tlc
orsldrtert.tlc
. The software creates theSimulink Desktop Real-Timeconfiguration set only if one does not exist.
Enter Configuration Parameters Manually
The configuration parameters give information to Simulink software for running a simulation.
This procedure uses the modelsldrtex_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 theDesktop Real-Timetab, clickHardware Settings. In the Configuration Parameters dialog box, click theSolvertab.
In theStart timefield, enter
0.0
. In theStop timefield, enter the amount of time you want your model to run. For example, enter10.0
seconds.From theTypelist, select
Fixed-step
.Simulink Coder™does not support variable step solvers.From theSolverlist, select a solver. For example, select the general-purpose solver
ode5 (Dormand-Prince)
.UnderAdditional options, in theFixed step sizefield, enter a sample time. For example, enter
0.001
seconds for a sample rate of1000
samples/second.Leave the parameterTreat each discrete rate as a separate taskcleared. (For models with blocks that have different sample times, select this parameter.)
ClickOK.
Enter Scope Parameters for Signal Tracing
You enter or change scope parameters to specify thex-axis andy-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 aScopeblock to your Simulink model, you can enter the scope parameters for signal tracing:
In the Simulink Editor, double-click theScopeblock.
On the toolbar, click theParametersbutton
.
Click theMaintab. In theSample timetext box, enter
-1
, which indicates that this block inherits its value from its parent model. If you have discrete blocks in your model, enter theFixed step sizevalue that you entered in the Configuration Parameters dialog box.Click theTimetab. In theTime spanbox, enter
1
.Click theDisplaytab. In theY-minandY-maxtext boxes, enter the range for they-axis in the Scope window. For example, enter
-2
and2
.ClickOK.