Main Content

addTolerance

Class: fxpOptimizationOptions

Specify numeric tolerance for optimized system

Syntax

addTolerance(options,blockPath,portIndex,tolType,tolValue)
addTolerance(options,blockPath,portIndex,tolType,tolValue,'LoggingInfo',logInfo)

Description

addTolerance(options,blockPath,portIndex,tolType,tolValue) specifies a numeric tolerance for the output signal specified by blockPath and portIndex, with the tolerance type specified by tolType and value specified by tolValue.

addTolerance(options,blockPath,portIndex,tolType,tolValue,'LoggingInfo',logInfo) specifies a tolerance and options for logging information with Simulink.SimulationData.LoggingInfo.

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 blockPath 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'.

You can specify a tolerance band using a combination of absolute, relative, and time tolerance values. When you specify the tolerance for your signal using multiple types of tolerances, the overall tolerance band is computed by selecting the most lenient tolerance result for each data point.

When you define your tolerance using only the absolute and relative tolerance properties, the tolerance for each point is computed as a simple maximum.

tolerance = max(absoluteTolerance,relativeTolerance*abs(baselineData));

For detailed information on tolerance computation, see Tolerance Computation.

Data Types: char

Acceptable level of tolerance for the signal specified by blockPath and portIndex.

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

If tolType is set to 'RelTol', then tolValue 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 tolType is set to 'TimeTol', then tolValue defines a time interval, in seconds, in which the maximum and minimum values define the upper and lower values to compare against.

You can specify a tolerance band using a combination of absolute, relative, and time tolerance values. When you specify the tolerance for your signal using multiple types of tolerances, the overall tolerance band is computed by selecting the most lenient tolerance result for each data point.

When you define your tolerance using only the absolute and relative tolerance properties, the tolerance for each point is computed as a simple maximum.

tolerance = max(absoluteTolerance,relativeTolerance*abs(baselineData));

For detailed information on tolerance computation, see Tolerance Computation.

Data Types: double

Optional signal logging settings, specified as a name-value pair where logInfo is a Simulink.SimulationData.LoggingInfo object. Use this input argument to specify a Decimation value to control the amount of data logged by the Simulation Data Inspector.

Example: logInfo = Simulink.SimulationData.LoggingInfo(); logInfo.DecimateData = true; logInfo.Decimation = 10; addTolerance(options, 'model/blockPath',2,'AbsTol',1,'LoggingInfo',logInfo);

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      

Version History

Introduced in R2018a

expand all