MATLAB provides these relational operators.
||Less than or equal to
||Greater than or equal to
||Not equal to
Relational Operators and Arrays
The MATLAB relational operators compare corresponding elements of arrays with equal dimensions. Relational operators always operate element-by-element. In this example, the resulting matrix shows where an element of
A is equal to the corresponding element of
For vectors and rectangular arrays, both operands must be the same size unless one is a scalar. For the case where one operand is a scalar and the other is not, MATLAB tests the scalar against every element of the other operand. Locations where the specified relation is true receive logical
1. Locations where the relation is false receive logical
Relational Operators and Empty Arrays
The relational operators work with arrays for which any dimension has size zero, as long as both arrays are the same size or one is a scalar. However, expressions such as
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
To test for empty arrays, use the function
© 1994-2005 The MathWorks, Inc.