isequaln

Tests array equality, treating NaN values as equal.

Category: Language Fundamentals > Operators and Elementary Operations

Syntax

tf = isequaln(A, B)

Returns true if A and B have the same size and equal elements, with NaN equal to NaN.

tf = isequaln(A, B, C, ...)

Compares all arguments to each other.

Description

It works exactly like isequal except that NaN in one array matches NaN at the same position in the other. That makes it the right choice for checking that two results with missing data agree, for instance two outputs of a computation that uses NaN as a marker.

The sizes must still match and all non-NaN values must be equal.

Input arguments

A, B, ...
Values of any type: numeric arrays, text, cell arrays, structs and so on.

Output arguments

tf
A single logical scalar.

Example

a = [1 NaN 3];
isequal(a, a)
isequaln(a, a)
isequaln([1 NaN], [1 2])
Output
ans = logical
   0
ans = logical
   1
ans = logical
   0

See also

isequal isnan ismissing ==