# min

Smallest element

### [M, I] = min(A)

• When A is a scalar, M is equal to A.
• When A is a vector, M is the smallest element of A.
• When A is a matrix or a multidimensional array, an element of M is equal to the smallest element of the corresponding vector of A along its first non-singleton dimension.
• I is the position of that smallest element in the direction of the non-singleton dimension.

### [M, I] = min(A, [ ], k)

• This is the same as the previous cases, except that each element of M corresponds to a vector of A along its k-th dimension.

### min(A, B)

• A and B should have same sizes.
• It performs elementwise comparison of A and B, and returns the smaller element.
• If one of the arguments is scalar, this function compares the scalar with each element of the other argument.

Note

When comparing two numbers by min, if one of them is NaN, the other non-NaN number is returned. If both are NaN, it returns NaN.