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:

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

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

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

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

  • Adjust parameter precision loss diagnostic configuration parameters within the app.

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, you can use the app only 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 this command.

    parameterQuantizationAdvisor('block_path','parameter_name')

Examples

expand all

Use the Parameter Quantization Advisor app to explore parameter precision loss in a Simulink model.

Open the sldemo_fuelsys model.

open_system('sldemo_fuelsys')

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

Simulate the model.

The Diagnostic Viewer displays 21 warnings for parameter precision loss.

To inspect the details of these diagnostics in the Parameter Quantization Advisor app, from the Suggested Actions, click Open. By default, the app shows quantization issues related to overflow, underflow, and precision loss.

In this example, the model has only precision loss issues, as indicated by a blue square in the Issue column of the table. You can confirm this by deselecting the Precision Loss filter in the toolstrip to see that there are no overflow or underflow issues to report.

You can use the Parameter Explorer pane to search and navigate to parameters in the model that have quantization loss. The Parameter Details pane shows that all of the precision loss warnings are due to conversion from double precision to single precision data types.

To suppress these precision loss warnings, select the Suppress double to single detection checkbox. Click Apply and Update to apply this setting to the model, compile the model, and update the data in the app based on the settings in the toolstrip. After suppressing double to single precision loss diagnostics, the app indicates that the model has no quantization issues to display.

Similarly, if you want to filter parameter precision loss diagnostics beneath a certain threshold, use the Absolute difference threshold and Relative difference threshold settings. You can also set the Detect precision loss diagnostic to none, warning, or error from the Parameter Quantization Advisor toolstrip.

The Model Configuration Parameters pane displays the current diagnostic settings on the model related to parameter quantization issues. To adjust settings related to overflow and underflow detection, click the Model Settings button to open the Configuration Parameters dialog box. After applying the new settings to the model, in the Parameter Quantization Advisor app, click Refresh Data to compile the model and update the data displayed in the app.

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 can prevent you from opening the Parameter Quantization Advisor app.

  • The Parameter Explorer displays a hierarchical tree of parameters in the model that have quantization issues. You can enter a string to search for a particular element in this tree. To view additional details, select the parameter you want to inspect.

  • The Parameter Explorer tree hierarchy displays nodes only for parameters that have quantization loss. The tree hierarchy does not display parameters that are lossless. When you filter data in the app, the tree hierarchy reflects this filtering.

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

    By default, the Parameter Quantization Advisor app hides the parameter overflow and precision loss diagnostics that these parameters suppress or filter out via threshold settings. To display these diagnostics in the app, use the Parameters Without Diagnostics button.

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

Version History

Introduced in R2022b

expand all