0 1 1
0 0 1
Empty Arrays
The relational operators work with arrays for which any dimension has size zero, as long
as both arrays have compatible sizes. This means that if one array has a dimension size of
zero, then the size of the corresponding dimension in the other array must be 1 or zero,
and the size of that dimension in the output is zero.
A = ones(3,0);
B = ones(3,1);
A == B
ans =
Empty matrix: 3-by-0
However, expressions such as
A == []
return an error if A is not 0-by-0 or 1-by-1. This behavior is consistent with that of all
other binary operators, such as +, -, >, <, &, |, and so on.
To test for empty arrays, use isempty(A).
Complex Numbers
- The operators >, <, >=, and <= use only the real part of the operands in performing
comparisons. - The operators == and ~= test both real and imaginary parts of the operands.
Inf, NaN, NaT, and undefined Element Comparisons
- Inf values are equal to other Inf values.
- NaN values are not equal to any other numeric value, including other NaN values.
- NaT values are not equal to any other datetime value, including other NaT values.
- Undefined categorical elements are not equal to any other categorical value, including
other undefined elements.
Array Comparison with Relational Operators