main Content

min

minimum elements of an array

描述

例子

m= min(min一个返回数组的最小元素。

  • 如果一个是一个向量,然后最小(A)返回最低一个

  • 如果一个是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 becomes1while 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一个,[],,暗淡返回the minimum element along dimension暗淡。例如,如果一个是a matrix, thenmin(a,[],2)是包含每一行的最小值的列向量。

例子

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

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

例子

[[m,,,,] = min(___also returns the index into the operating dimension that corresponds to the minimum value of一个对于以前的任何语法。

例子

m= min(min一个,[],,'全部'找到最低限度的所有元素一个。此语法对MATLAB有效®版本R2018B及以后。

例子

m= min(min一个,[],,vecdimcomputes the minimum over the dimensions specified in the vectorvecdim。例如,如果一个是a matrix, thenmin(a,[],[1 2])计算所有元素的最小值一个,,,,since every element of a matrix is contained in the array slice defined by dimensions 1 and 2.

m= min(min一个,[],,'全部',,,,nanflag计算所有元素的最低限度一个使用时nanflagoption.

m= min(min一个,[],,vecdim,,,,nanflagspecifies multiple dimensions to operate along when using thenanflagoption.

例子

[[m,,,,] = min(一个,[],,___,“线性”)返回the linear index into一个that corresponds to the minimum value in一个

例子

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

C= min(min一个,,,,b,,,,nanflagalso specifies how to treatvalues.

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×32 8 4 7 3 9
m =最小(A)
m =1×32 3 4

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

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

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 =南

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

a = [1 9 -2;8 4 -5]
a =2×319 -2 8 4 -5
[m,i] = min(一个)
m =1×31 4-5
我=1×31 22

Create a 3-D array and compute the minimum over each page of data (rows and columns).

a(::,:,1)= [2 4;-2 1];a(::,:,2)= [9 13;-5 7];a(::,:,3)= [4 4;8 -3];m1 = min(a,[],[1 2])
m1= M1(:,:,1) = -2 M1(:,:,2) = -5 M1(:,:,3) = -3

从R2018B开始,为了计算数组的所有维度的最小值,您可以指定向量维度参数中的每个维度,也可以使用'全部'option.

m2 = min(A,[],[1 2 3])
m2 = -5
mall = min(A,[],'全部'
mall = -5

Create a matrix一个and return the minimum value of each row in the matrixm。使用'linear'还可以返回线性索引的选项such thatm = a(i)

a =[[1 23; 4 5 6]
a =2×31 23 4 5 6
[m,i] = min(a,[],2,'linear'
m =2×11 4
我=2×11 2
minvals = A(I)
minvals =2×11 4

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

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

输入参数

全部收缩

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

  • 如果一个是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)是as well.

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

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

维操作,指定为是e integer scalar. If no value is specified, then the default is the first array dimension whose size does not equal 1.

Dimension暗淡指示长度降低到的维度1。Thesize(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返回一个如果暗淡是greater thanndims(A)

尺寸向量,指定为正整数的向量。每个元素代表输入阵列的维度。指定的操作尺寸中输出的长度为1,而其他功能保持不变。

Consider a 2-by-3-by-3 input array,一个。Thenmin(a,[],[1 2])返回a 1-by-1-by-3 array whose elements are the minimums computed over each page of一个

Data Types:double|single|int8|int16|int32|int64|uint8|uint16|uint32|uint64

附加输入数组,,,,specified as a scalar, vector, matrix, or multidimensional array. Inputs一个andb必须是相同的大小或具有兼容的尺寸(例如,一个是anm-by-n矩阵andb是标量或1-by-n行矢量)。有关更多信息,请参阅兼容阵列大小用于基本操作

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

  • 如果一个andbare ordinalcategoricalarrays, they must have the same sets of categories with the same order.

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

condition, specified as one of these values:

  • 'omitnan'-我gnore allvalues in the input. If all elements are, 然后min返回the first one.

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

为了datetimearrays, you can also use'omitnat'or'includenat'省略并包括纳特values, respectively.

为了categoricalarrays, you can also use'omitundefined'or'includeundefined'分别省略并包括不确定的值。

Data Types:char

Output Arguments

全部收缩

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

索引,作为标量,向量,矩阵或多维数组返回。是the same size as the first output.

When'linear'是not specified,是the index into the operating dimension. When'linear'指定,contains the linear indices of一个corresponding to the minimum values.

如果the smallest element occurs more than once, then包含该值首次出现的索引。

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

The 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

我ntroduced before R2006a