Propose Data Types For Merged Simulation Ranges

About This Example

This example shows how to use the Fixed-Point Tool to propose fraction lengths for a model based on the minimum and maximum values captured over multiple simulations. 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.

This example uses the ex_fpt_merge 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.

Simulate the Model Using Random Uniform Noise

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

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

  2. To open the Fixed-Point Tool, in the model menu, select Analysis > Data Type Design > Fixed-Point Tool.

  3. In the Prepare System section of the toolstrip, under System Under Design, select ex_fpt_merge as the system to convert.

  4. In the Collect Ranges section of the toolstrip, select Simulation Ranges as the method for range collection. Click the Collect Ranges button to override the data types in the model with doubles to observe the ideal numeric behavior of the model and enable range collection.

    Simulink® simulates the ex_fpt_merge model, using the random uniform noise signal. When the simulation is complete, the Fixed-Point Tool spreadsheet displays the simulation results for each block that logged fixed-point data. The tool stores the results in a run named Ranges (Double).

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

    SimMin is -3.5822

    SimMax is 2.7598

Simulate Model Using Band-Limited White Noise and Merge Ranges

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

  2. In the Fixed-Point Tool, click the Simulation Ranges button arrow and select the Merge min/max option.

  3. Click the Collect Ranges button.

    Simulink simulates the ex_fpt_merge model, now using the band-limited white noise input signal.

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

    The updated values are:

    SimMin is now -3.5822

    SimMax is now 3.1542

Propose Fraction Lengths Based on Merged Ranges

  1. In the Convert Data Types section of the toolstrip, click the Propose Data Types 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 cleared.

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

  2. Click the Apply Data Types button to write the proposed data types to the model.

Related Topics