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
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.
ex_fpt_merge model. At the MATLAB® command line,
To open the Fixed-Point Tool, in the model menu, select Analysis > Data Type Design > Fixed-Point Tool.
In the Prepare System section of the toolstrip, under
System Under Design, select
ex_fpt_merge as the
system to convert.
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
The SimMin and SimMax values for the Add block are:
In the model, double-click the switch to select the band-limited white noise signal.
In the Fixed-Point Tool, click the Simulation Ranges button arrow and select the Merge min/max option.
Click the Collect Ranges button.
Simulink simulates the
ex_fpt_merge model, now using the band-limited
white noise input signal.
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
SimMax is now
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.
Click the Apply Data Types button to write the proposed data types to the model.