## Documentation Center |

This example shows how to derive ranges for a model that contains multiple instances of the same referenced model.

On this page… |
---|

**Derive Ranges**

Open the

`ex_derived_sum_multi_instance`model. At the MATLAB^{®}command line, enter:addpath(fullfile(docroot,'toolbox','fixpoint','examples')) ex_derived_sum_multi_instance

The model displays the specified design minimum and maximum values for the blocks in the model.

The Inport block

`In1`has a design range of`[-50..100]`.The Inport block

`In2`has a design range of`[-50..35]`.

**Tip**To display design ranges in your model, from the model menu select**Display**>**Signals & Ports**and select**Design Ranges**.The model contains two Model blocks that both reference the

`ex_sum`model.Initially, the Sum block has no design range information.

From the

`ex_derived_sum_multi_instance`model**Analysis**menu, select**Fixed-Point Tool**.In the Fixed-Point Tool

**Model Hierarchy**pane, select the`ex_derived_sum_multi_instance`model.In the

**Settings for selected system**pane, set**Data type override**to`Double`.This global override of the fixed-point data types using double-precision numbers avoids quantization effects.

In the Fixed-Point Tool Data collection pane, set

**Store results in run**to`double_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.

In the Fixed-Point Tool

**Model Hierarchy**pane, select the`ex_sum`model.The

**Data type override**setting is`Off`. The setting in the parent model does not affect the setting in the referenced model — you must change it manually in the referenced model.For the

`ex_sum`model, set**Data type override**to`Double`and then click**Apply**.Changing the setting for any instance of the referenced model changes the setting on all instances and on the referenced model itself.

Save the models in a local writable folder.

The Fixed-Point Tool cannot derive ranges if your model contains unsaved changes.

In the Fixed-Point Tool, select the

`ex_derived_sum_multi_instance`model and then click**Derive min/max values for selected system**.To calculate the derived ranges, the software uses the design minimum and maximum values specified for the Inport blocks in the top-level model,

`In1`and`In2`.In the

**Contents**pane, the Fixed-Point Tool displays the derived and design minimum and maximum values for the blocks and referenced models in the`ex_derived_sum_multi_instance`model. Some of the derived values that the Fixed-Point Tool reports are slightly larger than expected. This difference is due to rounding errors because the software approximates floating-point numbers with infinite-precision rational numbers for analysis and then converts them to floating point for reporting.

**View Derived Ranges for Referenced Model**

In the

**Model Hierarchy**pane, select the first instance of the referenced model,`Model(ex_sum)`.The tool displays the derived minimum and maximum values for this instance of the referenced model,

`[-82.001..140.001]`. This range is derived from the outputs of the two Gain blocks,`[-40,80]`and`[-60..42.001]`.Select the second instance of the referenced model,

`Model1(ex_sum)`.The tool displays the derived values for the second instance,

`[-85..150]`. This range is derived from the referenced model inputs,`In1`and`In2`,`[-50..100]`and`[-50..35]`respectively.Select the node for the referenced model,

`ex_sum`.For this node, the Fixed-Point Tool displays the merged results for the derived range for the referenced model which is the union of the results for each instance of the model,

`[-85..150]`.

Next, you set design range on Sum block in referenced model to see how the range analysis takes this information into account.

**Add Design Range for Sum Block and Derive Ranges**

In the

`ex_sum`model, double-click the Sum block.In the block parameters dialog box, on the

**Signal Attributes**tab, set**Output minimum**to`-125`and**Output maximum**to`50`, click**OK**, and then save the model.In the Fixed-Point Tool, select the

`ex_derived_sum_multi_instance`model and then click**Derive min/max values for selected system**.This time, to calculate the derived ranges, the software uses the design minimum and maximum values specified for the Inport blocks in the parent model,

`In1`and`In2`, and the design minimum and maximum values specified for the Sum block in the referenced model.You can now propose data types for the model based on these derived minimum and maximum values.

Was this topic helpful?