addTolerance

Specify numeric tolerance for converted system

Description

example

addTolerance(proposalSettings,block_path,port_index,tolerance_type,tolerance_value) adds numeric tolerance data to a DataTypeWorkflow.ProposalSettings object 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.

Examples

collapse all

This example shows how to apply and remove tolerances from signals in a system. In this example, you add tolerances to a DataTypeWorkflow.proposalSettings object, and then remove all tolerances from this object.

model = 'fxpdemo_feedback';
open_system(model);

Create a DataTypeWorkflow.ProposalSettings object.

propSettings = DataTypeWorkflow.ProposalSettings;

Add an absolute tolerance of 0.05 to the output of the Down Cast block in the Controller subsystem.

addTolerance(propSettings, 'fxpdemo_feedback/Controller/Down Cast',1,'AbsTol',5e-2);

Add a relative tolerance of 1% to the same signal.

addTolerance(propSettings, 'fxpdemo_feedback/Controller/Down Cast',1,'RelTol',1e-2);

Use showTolerances to see all tolerances associated with the proposal settings object.

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

    {'fxpdemo_feedback/Controller/Down Cast'}        1           {'AbsTol'}           0.05      
    {'fxpdemo_feedback/Controller/Down Cast'}        1           {'RelTol'}           0.01      

Clear the tolerances stored in the ProposalSettings object.

clearTolerances(propSettings)

Using showTolerances, verify that there are no longer any tolerances stored in the ProposalSettings object.

showTolerances(propSettings)

Input Arguments

collapse all

Object that contains proposal settings, specified as a DataTypeWorkflow.ProposalSettings object. You add tolerance specifications to the DataTypeWorkflow.ProposalSettings object.

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

Data Types: char | string

Index of the output port of the blocks, specified as a scalar integer.

Data Types: double

Type of tolerance, specified as one of these values:

  • 'AbsTol' – Absolute tolerance

  • 'RelTol' – Relative tolerance

  • 'TimeTol' – Time tolerance

Data Types: char

Acceptable difference between the original output and the output of the new design, specified as a scalar double.

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 (Simulink).

Data Types: double

Introduced in R2019a