A < B
A > B
A <= B
A >= B
A == B
A ~= B
<
, <=
, >
, >=
, ==
, and ~=
. Relational operators perform element-by-element comparisons between two matrices. They return a matrix of the same size, with elements set to 1 where the relation is true, and elements set to 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.
produce the same result:X = 5; X >= [1 2 3; 4 5 6; 7 8 10]
X = 5*ones(3,3); X >= [1 2 3; 4 5 6; 7 8 10]
X =
1 1 1
1 1 0
0 0 0
&
,|
,~
,all
,any
,find
,strcmp
(c) Copyright 1994 by The MathWorks, Inc.