Package: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.Tolerance
Relative numeric tolerance
This numeric Tolerance
assesses the magnitude
of the difference between actual and expected values, relative to
the expected value. For the tolerance to be satisfied, abs(expVal
- actVal) <= relTol.*abs(expVal)
must be true.
RelativeTolerance(tolVals)
creates
a relative tolerance object that assesses the magnitude of the difference
between actual and expected values, relative to the expected value.
The data types of the inputs to the RelativeTolerance
constructor
determine which data types the tolerance supports. For example, RelativeTolerance(10*eps)
constructs
a RelativeTolerance
for comparing double-precision
numeric arrays while RelativeTolerance(int8(2))
constructs
a RelativeTolerance
for comparing numeric arrays of
type int8
. If the actual and expected values being
compared contain more than one numeric data type, the tolerance only
applies to the data types specified by the values passed into the
constructor.
To specify different tolerance values for different data types,
you can pass multiple tolerance values to the constructor. For example, RelativeTolerance(10*eps,
10*eps('single'), int8(1))
constructs an RelativeTolerance
that
applies the following absolute tolerances:
10*eps
applies a relative tolerance
of 10*eps
for double-precision numeric arrays.
10*eps('single')
applies a relative
tolerance of 10*eps
for single-precision numeric
arrays.
int8(1)
applies a relative tolerance
of 1
for numeric arrays of type int8
.
You can specify more than one tolerance for a particular data
type by combining tolerances with the &
and |
operators.
To combine two tolerances, the sizes of the tolerance values for each
data type must be compatible.
|
Numeric tolerances, specified as a comma-separated list of numeric arrays. Each input argument contains the tolerance specification for a particular data type. Each numeric array can be a scalar or array the same size as the actual and expected values. |
|
Numeric tolerances, specified by the |
Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.