Main Content

Configure a Model for Simulink Desktop 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, 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.

Specify a Default Configuration Set

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:

openExample('sldrtex_model')

It assumes that you have already loaded that model (see Create a Simulink Model).

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

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

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

Enter Configuration Parameters Manually

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:

openExample('sldrtex_model')

It assumes that you have already loaded that model.

  1. On the Desktop Real-Time tab, click Hardware Settings. In the Configuration Parameters dialog box, click the Solver tab.

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

  3. From the Type list, select Fixed-step. Simulink Coder™ does not support variable step solvers.

  4. From the Solver list, select a solver. For example, select the general-purpose solver ode5 (Dormand-Prince).

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

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

    These settings appear in the Solver tab of the Configuration Parameters dialog box.

  7. Click OK.

Enter Scope Parameters for Signal Tracing

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:

  1. In the Simulink Editor, double-click the Scope block.

  2. On the toolbar, click the Parameters button .

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

    These settings appear in the scope configuration properties dialog box.

  4. Click the Time tab. In the Time span box, enter 1.

    These settings appear in the time tab of the scope configuration properties dialog box.

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

    These settings appear in the display tab of the scope configuration properties dialog box.

  6. Click OK.

Related Topics