Documentation

Log Simulation Ranges for Referenced Models

This example shows how to log simulation minimum and maximum values for a model that contains multiple instances of the same referenced model.

Simulate the Model Using Local Settings

  1. Open the ex_mdlref_controller model. At the MATLAB® command line, enter:

    addpath(fullfile(docroot,'toolbox','fixpoint','examples'))
    ex_mdlref_controller

    The model contains a Model block that references the ex_controller model. Using a referenced model isolates the controller from the rest of the system. This method is useful to help you configure a model to determine the effect of fixed-point data types on a system. Using this approach, you convert only the referenced model because this is the system of interest.

  2. In the ex_mdlref_controller model menu, select Analysis > Fixed-Point Tool.

    The Fixed-Point Tool opens. In its Model Hierarchy pane, the tool displays two model nodes, one for the ex_mdlref_controller model showing that this model contains a Model block that refers to the ex_controller model, and another for the ex_controller model itself.

  3. Under System under design, click Continue to select ex_mdlref_controller as the subsystem you want to convert.

  4. Under Configure model settings, click the Range collection with specified data types button. This configuration sets:

    • Fixed-point instrumentation mode to Minimums, maximums and overflows.

    • Data type override to Use local settings so the model will log simulation data using the data types set up on the model.

  5. Under Range collection, set Run name to initial_run and then click Apply.

    Providing a unique name for the run avoids accidentally overwriting results from previous runs and enables you to identify the run more easily.

  6. In the Fixed-Point Tool, click Simulate model.

    Simulink® simulates the model. Afterward, the Fixed-Point Tool displays in its Contents pane the simulation results for each block that logged fixed-point data. By default, it displays the Simulation View of these results.

  7. In the Fixed-Point Tool Model Hierarchy pane, select the ex_controller model.

    The Fixed-Point tool displays the results for the referenced model and highlights the Up Cast block in red to indicate that there is an issue with this result. The OvfSat column for this result shows that the block saturated 23 times, which indicates poor scaling.

    Next, use data type override mode to perform a global override of the fixed-point data types and scaling using double-precision numbers to avoid quantization effects. Later, you use these simulation results when performing automatic data typing.

Gather a Floating-Point Benchmark

  1. Under Configure model settings, click the Range collection using double override button.

  2. Under Range collection, set Run name to double_run and then click Apply.

  3. In the Fixed-Point Tool, click Simulate.

    Simulink simulates the ex_mdlref_controller model in data type override mode and stores the results in the run named double_run. Afterward, the Fixed-Point Tool displays in its Contents pane the results along with those of the run that you generated previously.

  4. Use the Simulation Data Inspector to view the initial_run and double_run versions of the signal associated with the Analog Plant output. In the Contents pane, select the Analog Plant result. Click Compare Runs to launch the Simulation Data Inspector. The Simulation Data Inspector displays the two versions of the signal associated with the Analog Plant output (upper axes), and the difference between the signals (lower axes).

    Now you are ready to propose data types based on the simulation results from the doubles override run.

Related Examples

Was this topic helpful?