GT,,,,>
Determine greater than
Description
Examples
测试向量元素
确定向量元素是否大于给定值。
创建一个数字向量。
a =[1 12 18 7 9 11 2 15];
Test the vector for elements that are greater than10
。
a>10
ans =1x8逻辑数组01100101
结果是一个具有逻辑值的向量1
((true
) 在哪里the elements of一个
满足表达。
Use the vector of logical values as an index to view the values in一个
大于10
。
一个((一个>10)
ans =1×412 18 11 15
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 greater than9
with the value10
。
a(a> 9)= 10
a =4×41023 10 5 10 10 8 9 7 6 10 4 10 10 1
结果是一个新矩阵,其最大元素是10
。
Compare Values in Categorical Array
Create an ordinal categorical array.
a =categorical({'large''中等的''small';'中等的'...'small''large'},{'small''中等的''large'},'Ordinal',,,,1)
a =2x3分类大中小型中小型大小
阵列有三个类别:'small'
,,,,'中等的'
,,,,and'large'
。
找到大于类别的所有值'中等的'
。
a>'中等的'
ans =2x3逻辑数组100001
逻辑的价值1
((true
)indicates a value greater than the category'中等的'
。
比较行一个
。
a(1,:)> a(2,:)
ans =1x3 logical array110
The function returns logical1
((true
)第一行的类别值大于第二行。
Test Complex Numbers
创建一个复数的向量。
a =[1+i 2-2i 1+3i 1-2i 5-i];
找到大于2
。
A(a> 2)
ans = 5.0000 - 1.0000i
GT
仅比较一个
。
Use腹肌
to find which elements are outside a radius of2
来自原产地。
一个((腹肌((一个)>2)
ans =1×4复合物2。0000- 2.0000i 1.0000 + 3.0000i 1.0000 - 2.0000i 5.0000 - 1.0000i
The result has more elements since腹肌
计算数字的虚构部分。
比较日期
创建一个日期矢量。
a = dateTime([[2014,05,01; 2014,05,31])
a =2x1 datetime2014年5月1日至2014年3月31日
查找2014年5月10日之后发生的日期。
一个((一个>'2014-05-10')
ans =datetime2014年5月31日
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.
如果一个输入是n ordinal
categorical
数组,另一个输入可以是n ordinalcategorical
阵列,字符向量的单元格数组或单个字符向量。单个字符向量扩展到与其他输入相同大小的字符矢量的单元格数组中。如果两个输入都是序数categorical
数组,它们必须具有相同的类别集,包括其订单。看比较分类阵列元素for more details.如果一个输入是
datetime
数组,另一个输入可以是datetime
array, a character vector, or a cell array of character vectors.如果一个输入是
期间
数组,另一个输入可以是期间
数组或数字数组。操作员将每个数值视为24小时标准的许多标准值。如果一个输入是字符串数组,则另一个输入可以是字符串数组,字符向量或字符向量的单元格数组。相应的元素
一个
andb
are compared lexicographically.
数据类型:单身的
|double
|int8
|int16
|int32
|int64
|UINT8
|uint16
|UINT32
|Uint64
|逻辑
|char
|细绳
|categorical
|datetime
|期间
复杂的数字支持:万博1manbetx是的
扩展功能
高阵列
用比在内存中拟合更多的行的数组计算。
此功能完全支持高阵列。万博1manbetx有关更多信息,请参阅高阵列。
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
。
此功能完全支持基于线程的环境。万博1manbetx有关更多信息,请参阅在基于线程的环境中运行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,GT
supports implicit expansion when the arguments are ordinalcategorical
数组,datetime
数组,或期间
数组。在R2020a和R2016B之间,仅针对数字和字符串数据类型支持隐式扩展。万博1manbetx
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命令相对应的链接:
运行该命令通过输入MATLAB逗号nd 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)