le,<=
确定少于或等于
描述
例子
测试向量元素
Find which vector elements are less than or equal to a given value.
Create a numeric vector.
a = [1 12 18 7 9 11 2 15];
测试向量的元素小于或等于12
.
a <= 12
ans =1x8 logical array1 1 0 1 1 1 1 0
The result is a vector with values of logical1
(真的
)元素A
satisfy the expression.
使用逻辑值向量作为索引来查看值A
that are less than or equal to12
.
A(A <= 12)
ans =1×61 12 7 9 11 2
结果是元素的子集A
.
更换矩阵的元素
Create a matrix.
a =魔术(4)
A =4×416 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
替换所有小于或等于的值9
带有值10
.
A(A <= 9) = 10
A =4×416 10 10 13 10 11 10 10 10 10 10 12 10 14 15 10
结果是一个新矩阵,其最小元素是10
.
比较分类数组中的值
创建一个顺序的分类阵列。
a =分类({'大的''medium''小的';'medium'...'小的''大的'},{'小的''medium''大的'},,“序数”,1)
A =2x3 categoricallarge medium small medium small large
The array has three categories:'小的'
,'medium'
, 和'大的'
.
Find all values less than or equal to the category'medium'
.
a <='medium'
ans =2x3 logical array0 1 1 1 1 0
A value of logical1
(真的
) indicates a value less than or equal to the category'medium'
.
Compare the rows ofA
.
a(1,:) <= a(2,:)
ans =1x3逻辑数组0 0 1
该功能返回逻辑1
(真的
) where the first row has a category value less than or equal to the second row.
测试复数
Create a vector of complex numbers.
a = [1+i 2-2i 1+3i 1-2i 5-i];
Find the values that are less than or equal to3
.
A(a <= 3)
ans =1×4 complex1.0000 + 1.0000i 2.0000 - 2.0000i 1.0000 + 3.0000i 1.0000 - 2.0000i
le
compares only the real part of the elements inA
.
利用abs
to find which elements are within a radius of3
from the origin.
A(abs(A) <= 3)
ans =1×3 complex1.0000 + 1.0000i 2.0000 - 2.0000i 1.0000 - 2.0000i
The result has one less element. The element1.0000 + 3.0000i
不在半径内3
from the origin.
测试持续时间值
Create aduration
大批。
d =hours(21:25) + minutes(75)
d =1x5持续时间22.25 HR 23.25 HR 24.25 HR 25.25 HR 26.25 HR
测试阵列的小于或等于一个标准日的元素。
D <= 1
ans =1x5逻辑数组1 1 0 0 0
输入参数
A
,B
—操作数
标量|向量|矩阵|多维阵列
操作数,指定为标量,向量,矩阵或多维阵列。输入A
和B
must either be the same size or have sizes that are compatible (for example,A
是一个M
-经过-N
矩阵和B
是标量或1
-经过-N
行矢量)。有关更多信息,请参阅兼容阵列大小用于基本操作.
您可以比较任何类型的数字输入,并且该比较不会因类型转换而损失精度。
如果一个输入是序数
分类
数组,另一个输入可以是序数分类
array, a cell array of character vectors, or a single character vector. A single character vector expands into a cell array of character vectors of the same size as the other input. If both inputs are ordinal分类
数组, they must have the same sets of categories, including their order. SeeCompare Categorical Array Elements更多细节。如果一个输入是
约会时间
array, the other input can be a约会时间
数组,字符向量或字符向量的单元格数组。如果一个输入是
duration
array, the other input can be aduration
array or a numeric array. The operator treats each numeric value as a number of standard 24-hour days.如果一个输入是字符串数组,则另一个输入可以是字符串数组,字符向量或字符向量的单元格数组。相应的元素
A
和B
在词典上进行比较。
数据类型:single
|双倍的
|int8
|INT16
|INT32
|INT64
|uint8
|UINT16
|uint32
|uint64
|logical
|char
|string
|分类
|约会时间
|duration
Complex Number Support:Yes
提示
某些浮点数不能完全以二进制形式表示。这导致结果很小的差异
<=
操作员反映。有关更多信息,请参阅Avoiding Common Problems with Floating-Point Arithmetic.
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, seeTall Arrays.
C/C ++代码生成
使用MATLAB®CODER™生成C和C ++代码。
GPU Code Generation
使用GPU CODER™为NVIDIA®GPU生成CUDA®代码。
HDL代码生成
使用HDL Coder™生成用于FPGA和ASIC设计的Verilog和VHDL代码。
Thread-Based Environment
Run code in the background using MATLAB®背景池
或者accelerate code with Parallel Computing Toolbox™螺纹池
.
This function fully supports thread-based environments. For more information, seeRun MATLAB Functions in Thread-Based Environment.
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
此功能完全支持GPU数组。万博1manbetx有关更多信息,请参阅Run MATLAB Functions on a GPU(Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
此功能完全支持分布式数组。万博1manbetx有关更多信息,请参阅运行具有分布式数组的MATLAB功能(Parallel Computing Toolbox).
Version History
在R2006a之前引入R2020B:隐性扩展变化影响序数分类
数组,约会时间
数组,和duration
数组
R2020b中的行为发生了变化
从R2020B开始,le
万博1manbetx当论点是序数时,支持隐式扩展分类
数组,约会时间
数组, orduration
数组. Between R2020a and R2016b, implicit expansion was supported only for numeric and string data types.
R2016b:隐性扩展变更影响运营商的参数
Behavior changed in R2016b
与一个R2016b开始ddition of implicit expansion, some combinations of arguments for basic operations that previously returned errors now produce results. For example, you previously could not add a row and a column vector, but those operands are now valid for addition. In other words, an expression like[1 2] + [1; 2]
previously returned a size mismatch error, but now it executes.
If your code uses element-wise operators and relies on the errors that MATLAB®previously returned for mismatched sizes, particularly within a尝试
/抓住
块,那么您的代码可能不再捕获这些错误。
有关基本数组操作所需的输入尺寸的更多信息,请参见兼容阵列大小用于基本操作.
matlab命令
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)