Skip to Main Content Skip to Search
Product Documentation

Propose Data Types For a Model Using Results from Multiple Simulations

About This Example

This example demonstrates how to use the Fixed-Point Tool to propose fraction lengths for a model based on the simulation minimum and maximum values captured over multiple simulations.

This example uses the ex_fpt_merge_demo.mdl model.

About the Model

The model contains a sine wave input and two alternate noise sources, band-limited white noise and random uniform noise. The software converts the sine wave input and selected noise signal to fixed point and then adds them.

Merging Results from Two Simulation Runs

In this example, you use the Fixed-Point Tool to merge the results from two simulation runs. Merging results allows you to autoscale your model over the complete simulation range.

  1. Simulate the Model Using Random Uniform Noise. Using the Fixed-Point Tool, you simulate the model with the random uniform noise signal and observe the simulation minimum and maximum values for the Add block. The Fixed-Point Tool uses these simulation settings:

    • Fixed-point instrumentation mode: Minimums, maximums and overflows

    • Data type override: Double

    • Data type override applies to: All numeric types

    • Merge instrumentation results from multiple simulations is not selected.

    This run provides the simulation results for the random uniform noise input only.

  2. Simulate the Model Using Band-Limited White Noise. You select the band-limited white noise signal and run another simulation using the same Fixed-Point Tool simulation settings. The Fixed-Point Tool overwrites the results of the previous run.

    This run provides the simulation range for the band-limited white noise input only.

  3. Merge Results. You configure the Fixed-Point Tool to merge results. Select the random uniform noise input again, rerun the simulation, and observe the simulation results for the Add block.

    This run provides the simulation range based on the entire set of input data for both noise sources.

  4. Propose Fraction Lengths Based on Merged Results. The Fixed-Point Tool uses the merged simulation minimum and maximum values to propose scaling for each block to ensure maximum precision while spanning the full range of simulation values.

Running the Simulation

Simulate the Model Using Random Uniform Noise

  1. Open the ex_fpt_merge_demo.mdl model.

  2. From the model main menu, select Tools > Fixed-Point Tool.

  3. On the Fixed-Point Tool Shortcuts to set up runs pane, click the Model-wide double override and full instrumentation button to set:

    • Data type override to Double. This option enables each of the model's subsystems to use its locally specified data type settings.

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

    • The run name to DoubleOverride.

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

    The Simulink software simulates the ex_fpt_merge_demo model, using the random uniform noise signal. Afterward, the Fixed-Point Tool Contents pane displays the simulation results for each block that logged fixed-point data. The tool stores the results in a run named DoubleOverride, denoted by the DoubleOverride label in the Run column.

  5. The SimMin and SimMax values for the Add block are:

    SimMin is -3.5822

    SimMax is 2.7598

Simulate the Model Using Band-Limited White Noise

  1. In the model, double-click the switch to select the band-limited white noise signal.

  2. In the Fixed-Point Tool, click the Simulate button.

    The Simulink software simulates the ex_fpt_merge_demo model, now using the band-limited white noise signal.

  3. The changed values for SimMin and SimMax for the Add block are:

    SimMin is now-2.5317

    SimMax is now 3.1542

Merge Results

  1. In the model, double-click the switch to select the random uniform noise signal.

  2. On the Fixed-Point Tool Data collection pane, select Merge instrumentation results from multiple simulations, click Apply and rerun the simulation.

  3. The SimMin and SimMax values for the Add block now cover the entire simulation range for both the random uniform and band-limited white noise signals.

    SimMin is -3.5822

    SimMax is 3.1542

Propose Fraction Lengths Based on Merged Results

  1. On the Automatic data typing for selected system pane, click the Propose fraction lengths button.

    The Fixed-Point Tool analyzes the data types of all fixed-point blocks whose:

    • Lock output data type setting against changes by the fixed-point tools parameter is not selected.

    • Output data type parameter specifies a generalized fixed-point number.

    • Data types are not inherited.

    The Fixed-Point Tool uses the merged minimum and maximum values to propose fraction lengths for each block. These values ensure maximum precision while spanning the full range of simulation values. The tool displays the proposed data types in the Contents pane.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS