Documentation

Derive Ranges for a Referenced Model

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

Derive Ranges

  1. 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
    Save the model and the referenced model, ex_sum, in a local writable folder.

    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.

  2. From the ex_derived_sum_multi_instance model, select Analysis > Fixed-Point Tool.

  3. Under System under design, click Continue to select ex_derived_sum_multi_instance as the system you want to convert.

  4. Under Configure model settings, click Range collection using double override.

    This global override of the fixed-point data types using double-precision numbers avoids quantization effects.

  5. Under Range collection, set Run name 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.

  6. Save the models.

  7. In the Fixed-Point Tool, under Range collection, click the Derive ranges for system under design button.

    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

  1. 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].

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

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

  1. In the ex_sum model, double-click the Sum block.

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

  3. Under Range collection, click the Derive ranges for system under design button.

    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.

  4. You can now propose data types for the model based on these derived minimum and maximum values.

Related Examples

More About

Was this topic helpful?