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`

largest elements of array

`B = maxk(A,k)`

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

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

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

returns the `B`

= maxk(`A`

,`k`

)`k`

largest elements of `A`

.

If

`A`

is a vector, then`maxk`

returns a vector containing the`k`

largest elements of`A`

.If

`A`

is a matrix, then`maxk`

returns a matrix whose columns contain the`k`

largest elements of each column of`A`

.If

`A`

is a multidimensional array, then`maxk`

returns the`k`

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