feqmt, fgemt, fgtmt, flemt, fltmt, fnemt

Purpose

Fuzzy comparison functions. These functions use the fcmptol argument to fuzz the comparison operations to allow for roundoff error.

Format

ret = feqmt(a, b, fcmptol)
ret = fgemt(a, b, fcmptol)
ret = fgtmt(a, b, fcmptol)
ret = flemt(a, b, fcmptol)
ret = fltmt(a, b, fcmptol)
ret = fnemt(a, b, fcmptol)
Parameters:
  • a (NxK matrix) – first matrix.

  • b (LxM matrix) – second matrix, ExE compatible with a.

  • fcmptol (scalar) – comparison tolerance.

Returns:

ret (scalar) – returns 1 if TRUE and 0 if FALSE.

Examples

Example 1: Fuzzy equality

tol = 1e-12;

ret = feqmt(2, 2 + 1e-13, tol);

The above code will set ret equal to 1, because 2 and (2 + 1e-13) differ by less than the value of tol, which is 1e-12.

Example 2: Fuzzy greater than

tol = 1e-10;

a = 0.5;
b = a + 1e-5;
c = a + 1e-11;

ret_1 = fgtmt(b, a, tol);

ret_2 = fgtmt(c, a, tol);

After the code above:

ret_1 = 1
ret_2 = 0

Remarks

The return value is TRUE if every comparison is TRUE.

The statement:

ret = feqmt(a, b, 1e-15);

is equivalent to:

ret = abs(a-b) <= 1e-15;

For the sake of efficiency, these functions are not written to handle missing values. If a and b contain missing values, use missrv() to convert the missing values to something appropriate before calling a fuzzy comparison function.

Source

fcomparemt.src