Main Content

isequaln

Determine equality of fixed-point arrays, treating NaN values as equal

Since R2021a

Description

example

tf = isequaln(A,B) returns logical 1 (true) if A and B are equivalent; otherwise, it returns logical 0 (false). Arrays are considered equivalent if they are the same size and are numerically equal. NaN (Not a Number) values are considered to be equal to other such values.

Numeric data types and structure field order need not match to be considered equivalent.

isequaln recursively compares the contents of cell arrays and structures. If all elements of a cell array or structure are numerically equal, isequaln returns logical 1 (true).

tf = isequaln(A1,A2,…,An) returns logical 1 (true) if all the inputs are equivalent.

Examples

collapse all

Create two numeric matrices and compare them for equality.

A = fi(zeros(3,3)+1e-4,1,16,15);
B = fi(zeros(3,3),1,16,15);
tf = isequaln(A,B)
tf = logical
   0

The function returns logical 0 (false) because the matrices differ by a small amount and are not exactly equal.

If the two matrices differ by an amount that is smaller than the precision representable by the fixed-point data type, the function returns logical 1 (true).

A = fi(zeros(3,3)+1e-5,1,16,15);
B = fi(zeros(3,3),1,16,15);
tf = isequaln(A,B)
tf = logical
   1

Two matrices can be considered numerically equivalent when the inputs are of different data types.

A = fi(zeros(3,3),1,16,15);
B = single(zeros(3,3));
tf = isequaln(A,B)
tf = logical
   1

Input Arguments

collapse all

Inputs to be compared, specified as arrays.

Data Types: fi
Complex Number Support: Yes

Series of inputs to be compared, specified as arrays.

Data Types: fi
Complex Number Support: Yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2021a

See Also

|