le,,,,<=
Determine less than or equal to
Description
Examples
测试向量Elements
查找哪些矢量元素小于或等于给定值。
创建一个数字向量。
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一种
。
Replace Elements of Matrix
创建一个矩阵。
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 to9
with 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
。
Compare Values in Categorical Array
创建一个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
)第一行的类别值小于或等于第二行。
Test Complex Numbers
创建一个复数的向量。
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.0000i
is not within a radius of3
来自原产地。
Test Duration Values
创建一个期间
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
一种
,,,,b
-操作数
scalars|vectors|matrices|multidimensional arrays
操作数,,,,specified as scalars, vectors, matrices, or multidimensional arrays. Inputs一种
andb
必须是相同的大小或具有兼容的尺寸(例如,一种
is anm
-by-n
matrix andb
is a scalar or1
-by-n
row 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 ordinal
categorical
数组,另一个输入可以是n ordinalcategorical
阵列,字符向量的单元格数组或单个字符向量。单个字符向量扩展到与其他输入相同大小的字符矢量的单元格数组中。如果两个输入都是序数categorical
数组,它们必须具有相同的类别集,包括其订单。看比较分类阵列元素for more details.If one input is a
datetime
数组,另一个输入可以是datetime
array, 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
一种
andb
are 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避免浮点算术的常见问题。
扩展功能
高阵列
用比在内存中拟合更多的行的数组计算。
此功能完全支持高阵列。金宝app有关更多信息,请参阅高阵列。
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™.
基于线程的环境
使用MATLAB®在后台运行代码backgroundPool
或使用并行计算工具箱加速代码™ThreadPool
。
此功能完全支持基于线程的环境。金宝app有关更多信息,请参阅在基于线程的环境中运行MATLAB功能。
GPU数组
一种ccelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see在GPU上运行MATLAB功能(并行计算工具箱)。
分布式阵列
使用Parallel Computing Toolbox™,将群集组合内存的组合存储器划分。
This function fully supports distributed arrays. For more information, seeRun MATLAB Functions with Distributed Arrays(并行计算工具箱)。
版本历史记录
Introduced before R2006aR2020b: Implicit expansion change affects ordinalcategorical
数组,datetime
数组,and期间
arrays
behavior changed in R2020b
Starting in R2020b,le
supports implicit expansion when the arguments are ordinalcategorical
数组,datetime
数组,或期间
数组。在R2020a和R2016B之间,仅针对数字和字符串数据类型支持隐式扩展。金宝app
R2016b: Implicit expansion change affects arguments for operators
R2016b中的行为发生了变化
从R2016B开始,随着添加隐式扩展,以前返回错误的基本操作的某些参数的组合现在产生结果。例如,您以前无法添加一行和列向量,但是这些操作数现在对添加有效。换句话说,表达[1 2] + [1;2]
以前返回了尺寸不匹配错误,但现在执行。
如果您的代码使用元素操作员,并依赖MATLAB的错误®先前返回的尺寸不匹配的大小,尤其是在try
/catch
block, then your code might no longer catch those errors.
For more information on the required input sizes for basic array operations, seeCompatible Array Sizes for Basic Operations。
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
m一种TLAB Command
您单击了与此MATLAB命令相对应的链接:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
选择一个网站以获取可用的翻译内容,并查看本地事件和优惠。根据您的位置,我们建议您选择:。
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
一种mericas
- 一种mérica Latina((Español)
- Canada((English)
- United States((English)