Main Content

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 thesldrtconfigsetfunction to specify a defaultSimulink Desktop Real-Timeconfiguration set for the model. Usually, usingsldrtconfigsetprovides 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).

  1. 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 filesldrtex_model.

  2. In the MATLAB®Command Window, type:

    sldrtconfigset('sldrtex_model')

    The defaultSimulink Desktop Real-Timeconfiguration set,SimulinkDesktopRealTime, is now active for thesldrtex_modelmodel.

  3. 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.tlcorsldrtert.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.

  1. On theDesktop Real-Timetab, clickHardware Settings. In the Configuration Parameters dialog box, click theSolvertab.

  2. In theStart timefield, enter0.0. In theStop timefield, enter the amount of time you want your model to run. For example, enter10.0seconds.

  3. From theTypelist, selectFixed-step.Simulink Coder™does not support variable step solvers.

  4. From theSolverlist, select a solver. For example, select the general-purpose solverode5 (Dormand-Prince).

  5. UnderAdditional options, in theFixed step sizefield, enter a sample time. For example, enter0.001seconds for a sample rate of1000samples/second.

  6. Leave the parameterTreat each discrete rate as a separate taskcleared. (For models with blocks that have different sample times, select this parameter.)

    Image of configuration parameters solver window

  7. 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:

  1. In the Simulink Editor, double-click theScopeblock.

  2. On the toolbar, click theParametersbutton.

  3. 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.

    Image of scope parameters window

  4. Click theTimetab. In theTime spanbox, enter1.

    Image of scope parameters time window

  5. Click theDisplaytab. In theY-minandY-maxtext boxes, enter the range for they-axis in the Scope window. For example, enter-2and2.

    Image of scope axes properties window

  6. ClickOK.

Related Topics