if I have a vector of 20 elements, how can I extract the 5 minimum elements in that vector

1 Ansicht (letzte 30 Tage)
V=[23,56,12,90,45,21,56,10,70,100,15,...] a=[10,12,15,21,23]

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 2 Dez. 2017
sort() and take the first 5 elements of the output.

Weitere Antworten (1)

Steven Lord
Steven Lord am 2 Dez. 2017
If you're using release R2017b or later, use the mink function.

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by