<
Less-than operator: tests element by element whether A is smaller than B.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
C = A < B
Applies the operator to A and B. Same as lt(A, B).
Description
The comparison runs element by element with implicit expansion, so a matrix can be compared with a scalar or a row with a column. The result is a logical array that works as a mask: x(x < 0) picks the negative entries. Comparing with NaN always gives 0.
Char arguments are compared by their character codes.
Input arguments
A, B- Numeric, logical or char arrays (only the real part is compared for complex values). Sizes must be compatible, or one of them a scalar.
Output arguments
C- Logical array:
1where the relation holds,0elsewhere.
Example
x = [4 -1 7 0];
x < 3
x(x < 3)
[1 2 3] < [2; 3]
Output
ans = 1×4 logical array
0 1 0 1
ans = 1×2
-1 0
ans = 2×3 logical array
1 0 0
1 1 0