MATLAB Guide

MATLAB's relational operators are
| == | equal |
| ~= | not equal |
| < | less than |
| > | greater than |
| ? | less than or equal |
| ? | greater than or equal |
Note that a single = denotes assignment and never a test for equality in MATLAB.
Comparisons between scalars produce 1 if the relation is true and 0 if it is false. Comparisons are also defined between matrices of the same dimension and between a matrix and a scalar, the result being a matrix of 0s and 1s in both cases. For matrix-matrix comparisons corresponding pairs of elements are compared, while for matrix-scalar comparisons the scalar is compared with each matrix element. For example:
<span class="unicode">?</span> A = [1 2; 3 4]; B = 2*ones(2); <span class="unicode">?</span> A == B ans = 0 1 0 0 <span class="unicode">?</span> A > 2 ans = 0 0 1 1
To test whether matrices A and B are identical, the expression isequal(A,B) can be used:
<span class="unicode">?</span> isequal(A,B) ans = 0
The function isequal is one of many useful logical functions whose names begin with is, a...