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(
specifies a numeric tolerance for the output signal specified by
options
,blockPath
,portIndex
,tolType
,tolValue
)blockPath
and portIndex
, with the
tolerance type specified by tolType
and value specified by
tolValue
.
addTolerance(
specifies a tolerance and options for logging information with options
,blockPath
,portIndex
,tolType
,tolValue
,'LoggingInfo',logInfo
)Simulink.SimulationData.LoggingInfo
.
Input Arguments
options
— Associated fxpOptimizationOptions
object
fxpOptimizationOptions
fxpOptimizationOptions
object to add a tolerance
specification.
blockPath
— Path to block for which to add tolerance
block path name
Path to the block to add a tolerance to, specified as a character vector.
Data Types: char
| string
portIndex
— Index of output port of block
scalar integer
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
tolType
— Type of tolerance to specify
'AbsTol'
| 'RelTol'
| 'TimeTol'
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
tolValue
— Difference between the original output and the output of the new design
scalar double
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
'LoggingInfo',logInfo
— Optional signal logging settings
Simulink.SimulationData.LoggingInfo
object
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
Specify Required Numeric Tolerance for Optimized System
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 R2018aR2021b: Specify multiple types of tolerances
You can now specify multiple types of tolerances using the
addTolerance
function.
addTolerance(options,'model/blockPath',1,'AbsTol',5e-2,'RelTol',1e-2);
R2021b: Change in syntax for fxpOptimizationOptions.addTolerance
In previous releases, you specified options for logging information with a
Simulink.SimulationData.LoggingInfo
object as:
addTolerance(options,blockPath,portIndex,tolType,tolValue,loggingInfo)
Starting in R2021b, you must now specify logging information as a name-value pair:
addTolerance(options,blockPath,portIndex,... tolType,tolValue,'LoggingInfo',logInfo)
R2021a: Log a reduced set of data points
Using the addTolerance
method of the
fxpOptimizationOptions
object, you can now control the amount
of data logged by the Simulation Data Inspector by specifying a decimation
factor.
logInfo = Simulink.SimulationData.LoggingInfo(); logInfo.DecimateData = true; logInfo.Decimation = 10; addTolerance(options,'model/blockPath',2,'AbsTol',1,logInfo);
See Also
Classes
Functions
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)