main Content

GT,,,,>

Determine greater than

Description

例子

一个>b返回带有元素设置为逻辑1的逻辑数组(true) 在哪里一个is greater thanb;否则,该元素是合乎逻辑的0((错误的)。该测试仅比较数字阵列的实际部分。GT返回逻辑0((错误的) 在哪里一个orbhave NaN or undefinedcategorical元素。

gt(一个,,,,bis an alternate way to executea>b,但很少使用。它使运营商的载荷超载。

Examples

collapse all

确定向量元素是否大于给定值。

创建一个数字向量。

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一个

创建一个矩阵。

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 than9with the value10

a(a> 9)= 10
a =4×41023 10 5 10 10 8 9 7 6 10 4 10 10 1

结果是一个新矩阵,其最大元素是10

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)第一行的类别值大于第二行。

创建一个复数的向量。

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

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.

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

  • 如果一个输入是datetime数组,另一个输入可以是datetimearray, a character vector, or a cell array of character vectors.

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

  • 如果一个输入是字符串数组,则另一个输入可以是字符串数组,字符向量或字符向量的单元格数组。相应的元素一个andbare compared lexicographically.

数据类型:单身的|double|int8|int16|int32|int64|UINT8|uint16|UINT32|Uint64|逻辑|char|细绳|categorical|datetime|期间
复杂的数字支持:万博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™.

版本历史记录

Introduced before R2006a

expand all

behavior changed in R2020b

R2016b中的行为发生了变化