If A is a vector, then min(A) returns
the smallest element of A.

If A is a matrix, then min(A) treats
the columns of A as vectors and returns a row vector
of smallest elements.

If A is a multidimensional array,
then min(A) treats the values along the first array
dimension whose size does not equal 1 as vectors.
The size of this dimension becomes 1 while the
sizes of all other dimensions remain the same.

M = min(A,[],dim) returns
the smallest elements along dimension dim. For
example, if A is a matrix, then min(A,[],2) is
a column vector containing the minimum value of each row.

[M,I] =
min(___) finds the indices of the minimum values
of A and returns them in output vector I,
using any of the input arguments in the previous syntaxes. If there
are several identical minimum values, then min returns
the index of the first one.

To find the single smallest element in a matrix, you can
apply the min function twice, min(min(A)).
However, this does not return the index to the smallest element.

Use A(:) to find the minimum element in the
column representation of the elements from the array A.
Also return the index to the smallest element.

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

M =
2
I =
5

A(:) is a column vector composed of all the
columns from the matrix, where each column is appended to the last. A(5) returns
the minimum element, 2.

Input array, specified as a scalar, vector, matrix, or multidimensional
array. A can be a numeric array, logical array,
ordinal categorical array, datetime array, or duration array.

Dimension to operate along, specified as a positive integer
scalar. If no value is specified, the default is the first array dimension
whose size does not equal 1.

Dimension dim indicates the dimension whose
length reduces to 1. The size(M,dim) is 1,
while the sizes of all other dimensions remain the same, unless size(A,dim) is 0.
If size(A,dim) is 0, then min returns
an empty array with the same dimension sizes.

Consider a two-dimensional input array, A:

If dim = 1, then min(A,[],1) returns
a row vector containing the smallest element in each column.

If dim = 2, then min(A,[],2) returns
a column vector containing the smallest element in each row.

Second input array, specified as a scalar, vector, matrix, or
multidimensional array. B can be a numeric array,
logical array, ordinal categorical array, datetime array, or duration
array.

The dimensions of A and B must
match, or one can be a scalar.

If A and B are ordinal
categorical arrays, they must have the same sets of categories, including
their order.

A and B can be the same
data type or one can be double and combine with single,
any integer data type, or duration.

Minimum values, returned as scalar, vector, matrix, or multidimensional
array.

size(M,dim) is 1, while
the sizes of all other dimensions match the size of the corresponding
dimension in A, unless size(A,dim) is 0.
If size(A,dim) is 0, then M is
an empty array with the same dimension sizes as A.

Index to A, returned as an array the same
size as A. If the smallest element occurs more
than once, then I contains the index to the first
occurrence of the value.

The min function ignores NaNs.
When all elements in A are NaNs,
then min returns the first one as the minimum.
Undefined values in categorical arrays and NaT values
in datetime arrays are similar to NaNs in numeric
arrays.

When A is complex, the min function
returns the complex number with the smallest complex modulus (magnitude).
If magnitudes are equal, then min returns the
value with the smallest magnitude and the smallest phase angle.

When you use min(A,B) with an empty array
and a scalar, then min returns an empty array.