addTolerance

Class: fxpOptimizationOptions

Specify numeric tolerance for optimized system

Syntax

addTolerance(options,block_path,port_index,tolerance_type,tolerance_value)

Description

addTolerance(options,block_path,port_index,tolerance_type,tolerance_value) specifies a numeric tolerance for the output signal specified by block_path and port_index, with the tolerance type specified by tolerance_type and value specified by tolerance_value.

Input Arguments

expand all

fxpOptimizationOptions object to add a tolerance specification.

Path to the block to add a tolerance to, specified as a character vector.

Data Types: char | string

Index of output port of the block specified by block_path for which you want to specify a tolerance, specified as a scalar integer.

Data Types: double

Type of tolerance to add to the port indicated specified as either absolute tolerance, AbsTol, relative tolerance, RelTol, or time tolerance, TimeTol.

Data Types: char

Acceptable level of tolerance for the signal specified by block_path and port_index.

If tolerance_type is set to 'AbsTol', then tolerance_value represents the absolute value of the maximum acceptable difference between the original output, and the output of the new design.

If tolerance_type is set to 'RelTol', then tolerance_value represents the maximum relative difference, specified as a percentage, between the original output, and the output of the new design. For example, a value of 1e-2 indicates a maximum difference of one percent between the original output, and the output of the new design.

If tolerance_type is set to 'TimeTol', then tolerance_value defines a time interval, in seconds, in which the maximum and minimum values define the upper and lower values to compare against. For more information, see How the Simulation Data Inspector Compares Data.

Data Types: double

Examples

expand all

Load the system for which you want to optimize the data types.

load_system('ex_auto_gain_controller');

Create a fxpOptimizationOptions object with default property values.

options = fxpOptimizationOptions;

To specify a required numeric tolerance to use during the optimization process, use the addTolerance method of the fxpOptimizationOptions object. To specify several tolerance constraints, call the method once per constraint. You can specify either relative, or absolute tolerance constraints.

addTolerance(options, 'ex_auto_gain_controller/output_signal', 1, 'AbsTol', 5e-2);
addTolerance(options, 'ex_auto_gain_controller/input_signal', 1, 'RelTol', 1e-2);

Use the showTolerances method to display all tolerance constraints added to a specified fxpOptimizationOptions object.

showTolerances(options)
                      Path                       Port_Index    Tolerance_Type    Tolerance_Value
    _________________________________________    __________    ______________    _______________

    {'ex_auto_gain_controller/output_signal'}        1           {'AbsTol'}           0.05      
    {'ex_auto_gain_controller/input_signal' }        1           {'RelTol'}           0.01      


ans =

  2x4 table

                      Path                       Port_Index    Tolerance_Type    Tolerance_Value
    _________________________________________    __________    ______________    _______________

    {'ex_auto_gain_controller/output_signal'}        1           {'AbsTol'}           0.05      
    {'ex_auto_gain_controller/input_signal' }        1           {'RelTol'}           0.01      

Introduced in R2018a