Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Find `k`

smallest elements of array

`B = mink(A,k)`

`B = mink(A,k,dim)`

`B = mink(___,'ComparisonMethod',c)`

`[B,I] = mink(___)`

returns the `B`

= mink(`A`

,`k`

)`k`

smallest elements of `A`

.

If

`A`

is a vector, then`mink`

returns a vector containing the`k`

smallest elements of`A`

.If

`A`

is a matrix, then`mink`

returns a matrix whose columns contain the`k`

smallest elements of each column of`A`

.If

`A`

is a multidimensional array, then`mink`

returns the`k`

smallest elements along the first dimension whose size does not equal 1.