mink
Returns minimum values.
Syntax
m = mink(x, k)
m = mink(x, k, dim)
[m,idx] = mink(...)
Inputs
- x
- The matrix to query.
- k
- The number of values to return.
- dim
- The dimension on which to operate, or 'all'.
Outputs
- m
- The k minimum values in each dimension.
- idx
- The index of each minimum value.
Examples
Vector example:
m = [4,12,9,3,8,10,2,7,6,11,5,-8];
[v,idx] = mink(m, 5)
v = [Matrix] 1 x 5
-8 2 3 4 5
idx = [Matrix] 1 x 5
12 7 4 1 11
Matrix example:
m = [4,12,9,3,8,10;2,7,6,11,5,-8];
[v,idx] = mink(m, 5, 2)
v = [Matrix] 2 x 5
3 4 8 9 10
-8 5 6 7 11
idx = [Matrix] 2 x 5
4 1 5 3 6
6 5 3 1 4
Comments
For a single operand, the function returns the minimum elements of each vector in the specified dimension. If the second output is requested, it contains the single index of each minimum element.
NaN elements are ignored except when there are no numeric values to compare.