<=

Less-than-or-equal operator: tests element by element whether A is at most B.

Category: Language Fundamentals > Operators and Elementary Operations

Syntax

C = A <= B

Applies the operator to A and B. Same as le(A, B).

Description

Works like < but also accepts equality. Sizes follow implicit expansion rules and the result is a logical array. Any comparison involving NaN is 0, including NaN <= NaN.

With floating-point numbers, exact equality may fail because of rounding; compare with a tolerance when that matters.

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: 1 where the relation holds, 0 elsewhere.

Example

x = [1 2 3 4 5];
x <= 3
sum(x <= 3)
NaN <= NaN
Output
ans = 1×5 logical array

   1   1   1   0   0
ans = 3
ans = logical
   0

See also

le < >= == any