Documentation Center

  • Trial Software
  • Product Updates

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. In the Fixed-Point Tool Model Hierarchy pane, select the ex_mdlref_controller model.

  4. On the Settings for selected system pane, verify that:

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

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

  5. In the Fixed-Point Tool Data collection pane, set Store results in run 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. The fixed-point instrumentation and data type override settings for the top-level model do not affect the settings in the referenced model. In the Fixed-Point Tool Model Hierarchy pane, select the ex_controller model and verify that:

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

    • Data type override is set to Use local settings

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

    The Simulink® software 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.

    The Simulation Data Inspector tool opens. You can use this tool to inspect and compare signals in your model.

  8. 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 Saturations 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. In the Settings for selected system pane, set Data type override to Double.

  2. In the Data collection pane, set Store results in run to double_run and then click Apply.

  3. In the Model Hierarchy pane, select the ex_mdlref_controller model, set Data type override to Double and then click Apply.

    Setting data type override for the top-level model avoids data type propagation issues when you simulate the model.

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

    The Simulink software 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.

  5. Use the Simulation Data Inspector to view the initial_run and double_run 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.

Was this topic helpful?