文档

min

Smallest elements in array

句法

m =最小(A)
m =min(A,[],dim)
m = min(a,[],nanflag)
M = min([],暗,nanflag)
[m,i] = min(___
c = min(a,b)
c = min(a,b,nanflag)

Description

例子

m= min(min一个返回the smallest elements of一个

  • 如果一个是一个向量,然后最小(A)返回the smallest element of一个

  • 如果一个是a matrix, then最小(A)是a row vector containing the minimum value of each column.

  • 如果一个是a multidimensional array, then最小(A)沿着第一个数组尺寸运行,其大小不相等1,,,,treating the elements as vectors. The size of this dimension becomes1尽管the sizes of all other dimensions remain the same. If一个是an empty array with first dimension0, 然后最小(A)返回an empty array with the same size as一个

例子

m= min(min一个,[],,暗淡返回沿尺寸的最小元素暗淡。例如,如果一个是a matrix, thenmin(a,[],2)是包含每一行的最小值的列向量。

例子

m= min(min一个,[],,nanflagspecifies whether to include or omit计算中的值。例如,min(A,[],'includenan')包括全部values in一个尽管min(a,[],'omitnan')忽略它们。

m= min(min一个,[],,暗淡,,,,nanflagalso specifies the dimension to operate along when using thenanflagoption.

例子

[[m,,,,] = min(___找到最小值的指标一个并在输出向量中返回它们,,,,using any of the input arguments in the previous syntaxes. If the minimum value occurs more than once, thenmin返回the index corresponding to the first occurrence.

例子

C= min(min一个,,,,b返回一个阵列,带有最小的元素一个orb

C= min(min一个,,,,b,,,,nanflag也指定如何治疗values.

Examples

全部收缩

创建向量并计算其最小元素。

a =[[23 42 37 15 52]; M = min(A)
M = 15

创建一个复杂的向量并计算其最小元素,即具有最小幅度的元素。

a = [-2+2i 4+i -1-3i];最小(A)
ans =-2.0000 + 2.0000i

创建一个矩阵并计算每列中的最小元素。

a =[[2 8 4; 7 3 9]
a =2 8 4 7 3 9
m =最小(A)
m =2 3 4

创建一个矩阵并计算每一行中的最小元素。

a =[[1。7 1.2 1.5; 1.3 1.6 1.99]
a =1.7000 1.2000 1.5000 1.3000 1.6000 1.9900
m = min(a,[],2)
m =1.2000 1.3000

Create a matrix一个并计算每列中最小的元素以及一个他们出现的。

a = [1 9 -2;8 4 -5]
a =19 -2 8 4 -5
[m,i] = min(一个)
m =14 -5
我=1 2 2

Create a matrix and return the smallest value between each of its elements compared to a scalar.

a =[[17 3; 6 2 9]
a =17 3 6 2 9
b = 5;c = min(a,b)
C=15 3 5 2 5

Create a matrix一个and use its column representation,一个(:),找到最小元素的值和索引。

a =[[8 2 4; 7 3 9]
a =8 2 4 7 3 9
一个(:)
ans =8 7 2 3 4 9
[m,i] = min(a(:))
m =2
i = 3

是the index of一个(:)containing the smallest element.

现在,使用ind2sub提取行和列索引的功能一个对应于最小元素。

[[我_row, I_col] = ind2sub(size(A),I)
i_row = 1
I_COL = 2

如果您只需要最低值一个而不是其索引,请致电min功能两次。

m =min(min(A))
m =2

Create a vector and compute its minimum, excludingvalues.

a =[[1。77 -0.005 3.98 -2.95 NaN 0.34 NaN 0.19]; M = min(A,[],'omitnan'
M = -2.9500

最小(A)也将产生这个结果'omitnan'是the default option.

使用'includeenan'标志要返回

m =min(A,[],'includeenan'
m =南

输入参数

全部收缩

输入阵列,指定为标量,向量,矩阵或多维数组。

  • 如果一个是complex, then最小(A)返回最小幅度的复数。如果幅度相等,则最小(A)返回the value with the smallest magnitude and the smallest phase angle.

  • 如果一个是a scalar, then最小(A)返回一个

  • 如果一个是a 0-by-0 empty array, then最小(A)也是。

如果一个has typecategorical, 然后it must be ordinal.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|逻辑|categorical|约会时间|期间
复杂的数字支持:金宝appYes

沿着操作的维度,指定为正整数标量。如果未指定值,则默认值是第一个数组维度,其大小不等于1。

Dimension暗淡指示长度降低到的维度1。这size(M,dim)1,虽然所有其他维度的尺寸保持不变,除非大小(a,昏暗)0。如果大小(a,昏暗)0, 然后最小(a,昏暗)返回an empty array with the same size as一个

Consider a two-dimensional input array,一个

  • 如果暗淡= 1, 然后min(a,[],1)返回a row vector containing the smallest element in each column.

  • 如果暗淡= 2, 然后min(a,[],2)返回a column vector containing the smallest element in each row.

min返回一个如果暗淡大于ndims(A)

附加输入阵列,指定为标量,向量,矩阵或多维数组。数字输入一个andb必须是相同的大小或具有兼容的尺寸(例如,一个是anm-by-n矩阵andb是标量或1-by-n行矢量)。有关更多信息,请参阅兼容阵列大小用于基本操作

如果一个andbare datetime, duration, or categorical arrays, then they must be the same size unless one is a scalar.

  • 一个andbmust be the same data type unless one is adouble。在这种情况下,其他数组的数据类型可以是single,,,,期间,,,,or any integer type.

  • 如果一个andb是序数分类阵列,它们必须具有相同的类别集,并具有相同的顺序。

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|逻辑|categorical|约会时间|期间
复杂的数字支持:金宝appYes

条件,,,,specified as one of these values:

  • 'omitnan'-我gnore all输入中的值。

  • 'includeenan'-我nclude thevalues in the input for the calculation.

为了约会时间arrays, you can also use'omitnat'or'includenat'省略并包括纳特values, respectively.

min功能不支持金宝appnanflagoption forcategoricalarrays.

Data Types:char

Output Arguments

全部收缩

最小值,作为标量,向量,矩阵或多维数组返回。size(M,dim)1,,,,尽管the sizes of all other dimensions match the size of the corresponding dimension in一个,,,,unless大小(a,昏暗)0。如果大小(a,昏暗)0, 然后m是an empty array with the same size as一个

索引至最低值一个,,,,returned as a scalar, vector, matrix, or multidimensional array.是the same size asm。如果最小元素发生不止一次,则包含该值首次出现的索引。

minimum elements from一个orb,,,,returned as a scalar, vector, matrix, or multidimensional array. The size ofC通过隐式扩展的尺寸来确定一个andb。有关更多信息,请参阅兼容阵列大小用于基本操作

这data type ofCdepends on the data types of一个andb

  • 如果一个andb是相同的数据类型,然后Cmatches the data type of一个andb

  • 如果either一个orbsingle, 然后Csingle

  • 如果either一个orb是具有标量的整数数据类型double, 然后C假设整数数据类型。

Extended Capabilities

在R2006a之前引入

这个话题有帮助吗?