main Content

le,,,,<=

Determine less than or equal to

Description

例子

一种<=b返回带有元素设置为逻辑1的逻辑数组(true) 在哪里一种小于或等于b;否则,该元素是合乎逻辑的0((错误的)。该测试仅比较数字阵列的实际部分。le返回逻辑0((错误的) 在哪里一种orbhave NaN or undefinedcategorical元素。

le(一种,,,,bis an alternate way to execute一种<= B,但很少使用。它使运营商的载荷超载。

Examples

collapse all

查找哪些矢量元素小于或等于给定值。

创建一个数字向量。

a =[1 12 18 7 9 11 2 15];

Test the vector for elements that are less than or equal to12

一种<= 12
ans =1x8逻辑数组1 1 0 1 1 1 1 0

结果是一个具有逻辑值的向量1((true) 在哪里the elements of一种满足表达。

Use the vector of logical values as an index to view the values in一种小于或等于12

a(a <= 12)
ans =1×61 12 7 9 11 2

The result is a subset of the elements in一种

创建一个矩阵。

a =magic(4)
a =4×416 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1

Replace all values less than or equal to9with the value10

a(a <= 9)= 10
a =4×416 10 10 10 13 10 11 10 10 10 10 10 12 10 14 15 10

The result is a new matrix whose smallest element is10

创建一个n ordinal categorical array.

a =categorical({'large''中等的''small';'中等的'...'small''large'},{'small''中等的''large'},'Ordinal',,,,1)
a =2x3分类大中小型中小型大小

阵列有三个类别:'small',,,,'中等的',,,,and'large'

找到所有小于或等于类别的值'中等的'

一种<='中等的'
ans =2x3逻辑数组0 1 1 1 1 0

逻辑的价值1((true)指示一个小于或等于类别的值'中等的'

比较行一种

一种((1,,,,:) <= A(2,:)
ans =1x3 logical array0 0 1

The function returns logical1((true)第一行的类别值小于或等于第二行。

创建一个复数的向量。

a =[1+i 2-2i 1+3i 1-2i 5-i];

找到小于或等于的值3

一种((一种<= 3)
ans =1×4复合物1.0000 + 1.0000i 2.0000-2.0000i 1.0000 + 3.0000i 1.0000-2.0000i

le仅比较一种

Use腹肌查找哪些元素在半径内3来自原产地。

a(abs(a)<= 3)
ans =1×3复合物1.0000 + 1.0000i 2.0000-2.0000i 1.0000-2.0000i

结果的元素较小。元素1。0000+ 3.0000iis not within a radius of3来自原产地。

创建一个期间array.

D =小时(21:25) +分钟(75)
d =1x5 duration22.25 hr 23.25 hr 24.25 hr 25.25 hr 26.25 hr

Test the array for elements that are less than or equal to one standard day.

d <= 1
ans =1x5 logical array1 1 0 0 0

Input Arguments

collapse all

操作数,,,,specified as scalars, vectors, matrices, or multidimensional arrays. Inputs一种andb必须是相同的大小或具有兼容的尺寸(例如,一种is anm-by-nmatrix andbis a scalar or1-by-nrow vector). For more information, seeCompatible Array Sizes for Basic Operations

You can compare numeric inputs of any type, and the comparison does not suffer loss of precision due to type conversion.

  • If one input is an ordinalcategorical数组,另一个输入可以是n ordinalcategorical阵列,字符向量的单元格数组或单个字符向量。单个字符向量扩展到与其他输入相同大小的字符矢量的单元格数组中。如果两个输入都是序数categorical数组,它们必须具有相同的类别集,包括其订单。看比较分类阵列元素for more details.

  • If one input is adatetime数组,另一个输入可以是datetimearray, a character vector, or a cell array of character vectors.

  • If one input is a期间数组,另一个输入可以是期间数组或数字数组。操作员将每个数值视为24小时标准的许多标准值。

  • If one input is a string array, the other input can be a string array, a character vector, or a cell array of character vectors. The corresponding elements of一种andbare compared lexicographically.

Data Types:单身的|double|int8|int16|int32|int64|UINT8|uint16|UINT32|Uint64|逻辑|char|细绳|categorical|datetime|期间
复杂的数字支持:金宝app是的

Tips

  • Some floating-point numbers cannot be represented exactly in binary form. This leads to small differences in results that the<=operator reflects. For more information, see避免浮点算术的常见问题

扩展功能

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU代码生成
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

HDL Code Generation
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.

版本历史记录

Introduced before R2006a

expand all

behavior changed in R2020b

R2016b中的行为发生了变化