Main Content

Parameter Quantization Advisor

Inspect numerical issues related to parameter quantization

Since R2022b

Description

The Parameter Quantization Advisor app provides details on numerical issues related to parameter quantization. Using this app, you can:

  • Filter quantization issues resulting from parameter overflow, underflow, and precision loss.

  • Sort quantization issues based on bits of error, absolute error, or relative error.

  • Explore in detail the effects of parameter quantization on your model.

  • Explore all parameters in model that have quantization issues, including parameters with a structure value, bus objects, and Simulink.Parameter objects.

Required Products

A Fixed-Point Designer™ license is required to use the Parameter Quantization Advisor app with a model containing fixed-point data types. Without a Fixed-Point Designer license, the app can only be used on models containing built-in data types, including double, single, int8, int16, int32, int64, uint8, uint16, uint32, and uint64. This requirement applies to both dialog and run-time data types.

Screenshot of Parameter Quantization Advisor app.

Open the Parameter Quantization Advisor App

  • Diagnostic Viewer: From a numeric diagnostic warning or error, under Suggested Actions, click Open.

  • MATLAB® command prompt: Enter

    parameterQuantizationAdvisor('block_path','parameter_name')

Examples

expand all

Use the Parameter Quantization Advisor to explore parameter precision loss in a feedback controller model.

Open the fxpdemo_feedback model.

open_system("fxpdemo_feedback")

Check that parameter diagnostics are enabled. In the Configuration Parameters dialog, under Diagnostics > Data Validity, set the Detect precision loss parameter diagnostic to warning.

Simulate the model.

The Diagnostic Viewer displays a warning for parameter precision loss.

PQA_rel_err.png

To inspect the details of this diagnostic in the Parameter Quantization Advisor, from the Suggested Actions, click Open.

The app displays details of the parameter precision loss that occurred in fxpdemo_feedback/Denominator Terms. In this example, the model has only precision loss issues, as indicated by a blue square in the Quantization Issue column of the table. You can also use the app to explore overflow and underflow issues.

Four coefficients in the Discrete FIR Filter block named Denominator Terms experienced precision loss. The table shows the dialog value entered for each parameter and the corresponding quantized value of each parameter. You can sort the table by bits of error, absolute error, or relative error.

The Parameter Details pane contains additional details for the parameter experiencing numeric issues, including the location in the model and the name, dimension, and complexity of the parameter. The table displays the data type of the parameter in the dialog and the data type of the parameter at run time along with the minimum, maximum, and precision representable by these data types.

Programmatic Use

expand all

parameterQuantizationAdvisor('block_path','parameter_name') opens the Parameter Quantization Advisor app for a parameter with a structure value.

parameterQuantizationAdvisor('model_name','Simulink.Parameter_object_name') opens the Parameter Quantization Advisor app for a Simulink.Parameter object.

Limitations

  • Parameters with nested structures are not supported.

  • Structures with Simulink.Parameter objects are not supported.

Tips

  • Update the diagram or simulate the model to view messages in the Diagnostic Viewer.

  • You can open the Parameter Quantization Advisor app when the Detect underflow, Detect overflow, or Detect precision loss diagnostics error. Other errors that prevent the model from successfully compiling may prevent the Parameter Quantization Advisor app from being opened.

  • The Parameter Quantization Advisor app reports information for these quantization issues:

    Diagnostics set to none are also reported in the app.

    You can use these configuration parameters to filter parameter overflow and precision loss diagnostics:

    Parameter overflow and precision loss diagnostics that are suppressed or filtered out by these parameters by default hidden in the Parameter Quantization Advisor app. You can use the Parameters Without Diagnostics button to display these diagnostics in the app.

  • The Parameter Quantization Advisor reports details on quantization issues for tunable and nontunable parameters that experience quantization loss.

  • A hierarchical tree of parameters in the model that have quantization issues is displayed in the Parameter Explorer. You can enter a string to search for a particular element within this tree. Select the parameter you would like to inspect to view additional details.

    The Parameter Explorer tree hierarchy displays nodes only for parameters that have quantization loss. Parameters that are lossless are not displayed.

Version History

Introduced in R2022b

expand all