le

Less than or equal to, the function form of the operator <=.

Category: Symbolic Computations in MATLAB > Operators and Elementary Operations

Syntax

C = le(A, B)

Same as A <= B.

Description

The operator A <= B compares element by element and returns true where A is less than or equal to B. For complex numbers only the real parts are compared. Comparisons with NaN are false.

It is the usual way to build a mask for logical indexing, as in x(x <= 3).

Input arguments

A, B
Numeric, character or string arrays, or symbolic scalars. Sizes must be compatible (equal, or one is scalar, or broadcasting applies).

Output arguments

C
Logical array with the broadcast size. With symbolic operands, a symbolic relation such as x > 1.

Example

Elementwise and as a mask

le([1 2 3], [3 2 1])
x = [5 1 4 2];
x(le(x, 3))
Output
ans = 1×3 logical array

   1   1   0
ans = 1×2

     1     2

See also

lt ge gt ne eq