MATLAB Function Reference |

Test arrays for equality, treating `NaN`

s as equal

**Syntax**

**Description**

```
tf = isequalwithequalnans(A, B, ...)
```

returns logical `1`

(`true`

) if the input arrays are the same type and size and hold the same contents, and logical `0`

(`false`

) otherwise. `NaN`

(Not a Number) values are considered to be equal to each other. Numeric data types and structure field order do not have to match.

**Remarks**

`isequalwithequalnans`

is the same as `isequal`

, except `isequalwithequalnans`

considers `NaN`

(Not a Number) values to be equal, and `isequal`

does not.

`isequalwithequalnans`

recursively compares the contents of cell arrays and structures. If all the elements of a cell array or structure are numerically equal, `isequalwithequalnans`

returns logical `1`

.

**Examples**

Arrays containing `NaN`

s are handled differently by `isequal`

and `isequalwithequalnans`

. `isequal`

does not consider `NaN`

s to be equal, while `isequalwithequalnans`

does.

The position of `NaN`

elements in the array does matter. If they are not in the same position in the arrays being compared, then `isequalwithequalnans`

returns zero.

**See Also**

`isequal`

, `strcmp`

, `isa`

, is*, relational operators

isequal | isfield |

© 1994-2005 The MathWorks, Inc.