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

1 view (last 30 days)
V=[23,56,12,90,45,21,56,10,70,100,15,...] a=[10,12,15,21,23]

Accepted Answer

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

More Answers (1)

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

Categories

Find more on Time Series in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!