min

Returns minimum values.

Syntax

m = min(x)

m = min(x, [], dim)

[m,idx] = min(...)

m = min(x, y)

Inputs

x
The matrix to query.
Type: double | complex | integer
Dimension: scalar | vector | matrix
y
The second matrix for a pairwise query with x.
Type: double | complex | integer
Dimension: scalar | vector | matrix
dim
The dimension on which to operate, or 'all'.
Default: first non-singleton dimension.
Type: int | string

Outputs

m
The minimum value(s).
Dimension: scalar | vector | matrix
idx
The index of each minimum value. Not valid for a pairwise query.
Type: integer
Dimension: scalar | vector | matrix

Examples

Vector input with two outputs:

[m,idx] = min([7,1,5])
m = 1
idx = 2

Matrix input:

m = min([1,6;2,7])
m = [Matrix] 1 x 2
1 6

Matrix input with dimension:

m = min([1,6;2,5],[],1)
m = [Matrix] 1 x 2
1 5

Two matrix inputs:

m = min([1,6;2,5],[1,2;3,4])
m = [Matrix] 2 x 2
1  2
2  4

Comments

For a single operand, the function returns the minimum element of each vector in the specified dimension. If the second output is requested, it contains the single index of each minimum element.

For two operands with common dimensions, the function returns the minimum element from each element pair. If an operand is a single element, it is compared with each element of the other operand.