Main Content

fixed.unifiedErrorCalculator.relativeAbsoluteError

Relative absolute error of two numeric inputs

Since R2023b

Description

example

fixed.unifiedErrorCalculator.relativeAbsoluteError(approxValue,refValue) returns the relative absolute error between the approximate value approxValue and the reference value refValue given by abs(refValue-approxValue)/abs(refValue).

fixed.unifiedErrorCalculator.relativeAbsoluteError(approxValue,refValue,keepNaN) specifies whether to keep the calculated error as NaN. By default, to indicate the calculated error is significant, the function returns Inf if the calculated error is NaN.

Examples

collapse all

Use the fixed.unifiedErrorCalculator.relativeAbsoluteError function to compute the relative absolute error between a set of numerical values in double precision and the same set of values quantized to the int8 data type.

refValue = [-129 -128.5 -1.863 0 0.499 125.5 200];
approxValue = int8(refValue);
y = fixed.unifiedErrorCalculator.relativeAbsoluteError(approxValue,refValue)
y =

    0.0078    0.0039    0.0735         0    1.0000    0.0040    0.3650

Input Arguments

collapse all

Approximate or quantized value, specified as a scalar, vector, matrix, or multidimensional array. The input arguments approxValue and refValue must be real-valued and have the same size.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

Reference, ideal, or actual value to compare against, specified as a scalar, vector, matrix, or multidimensional array. The input arguments refValue and approxValue must be real-valued and have the same size.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

Whether to keep NaN results, specified as one of these values:

  • false or 0 — If the calculated error is NaN, return Inf to indicate that the calculated error is significant.

  • true or 1 — If the calculated error is NaN, return NaN.

Version History

Introduced in R2023b