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

1 vue (au cours des 30 derniers jours)
V=[23,56,12,90,45,21,56,10,70,100,15,...] a=[10,12,15,21,23]

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Déc 2017
sort() and take the first 5 elements of the output.

Plus de réponses (1)

Steven Lord
Steven Lord le 2 Déc 2017
If you're using release R2017b or later, use the mink function.

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by