matlab.unittest.constraints.RelativeTolerance class
Package: matlab.unittest.constraints
Superclasses: matlab.unittest.constraints.Tolerance
Relative numeric tolerance
Description
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.
Construction
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(single(2))
constructs a RelativeTolerance
for comparing single-precision numeric arrays. 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'))
constructs an RelativeTolerance
that applies the following absolute tolerances:
10*eps
applies a relative tolerance of10*eps
for double-precision numeric arrays.10*eps('single')
applies a relative tolerance of10*eps
for single-precision numeric arrays.
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.
Input Arguments
|
Numeric tolerances, specified as a comma-separated list of arrays containing floating-point numbers. 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. |
Properties
|
Numeric tolerances, specified by the |
Copy Semantics
Value. To learn how value classes affect copy operations, see Copying Objects.