MATLAB Function Reference
  Go to function:
    Search    Help Desk 
Relational Operators < > <= >= == ~=    Examples   See Also

Relational operations

Syntax

Description

The relational operators are <, , >, , ==, and ~=. Relational operators perform element-by-element comparisons between two arrays. They return an array of the same size, with elements set to logical true (1) where the relation is true, and elements set to logical false (0) where it is not.

The operators <, , >, and use only the real part of their operands for the comparison. The operators == and ~= test real and imaginary parts.

The relational operators have precedence midway between the logical operators and the arithmetic operators.

To test if two strings are equivalent, use strcmp, which allows vectors of dissimilar length to be compared.

Examples

If one of the operands is a scalar and the other a matrix, the scalar expands to the size of the matrix. For example, the two pairs of statements:

produce the same result:

See Also

Logical Operators & | ~

all         Test to determine if all elements are nonzero

any         Test for any nonzeros

find        Find indices and values of nonzero elements

strcmp      Compare strings



[ Previous | Help Desk | Next ]