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.
Logic Statements
Use relational operators in conjunction with the logical operators A & B (AND), A | B (OR),
xor(A,B) (XOR), and ~A (NOT), to string together more complex logical statements.
For example, you can locate where negative elements occur in two arrays.
A = [2 -1; -3 10]
A =
2
-1
-3
10
B = [0 -2; -3 -1]
B =
0
-2
-3
-1
A<0 & B<0
ans =
0
1
1
0
For more examples, see “Find Array Elements That Meet a Condition” on page 5-2.
See Also
gt | lt | ge | le | eq | ne
More About
•
“Array vs. Matrix Operations” on page 2-20
•
“Compatible Array Sizes for Basic Operations” on page 2-25
•
“MATLAB Operators and Special Characters” on page 2-2
Array Comparison with Relational Operators
2-31
• 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.
Logic Statements
Use relational operators in conjunction with the logical operators A & B (AND), A | B (OR),
xor(A,B) (XOR), and ~A (NOT), to string together more complex logical statements.
For example, you can locate where negative elements occur in two arrays.
A = [2 -1; -3 10]
A =
2
-1
-3
10
B = [0 -2; -3 -1]
B =
0
-2
-3
-1
A<0 & B<0
ans =
0
1
1
0
For more examples, see “Find Array Elements That Meet a Condition” on page 5-2.
See Also
gt | lt | ge | le | eq | ne
More About
•
“Array vs. Matrix Operations” on page 2-20
•
“Compatible Array Sizes for Basic Operations” on page 2-25
•
“MATLAB Operators and Special Characters” on page 2-2
Array Comparison with Relational Operators
2-31
