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

1 次查看(过去 30 天)
V=[23,56,12,90,45,21,56,10,70,100,15,...] a=[10,12,15,21,23]

采纳的回答

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

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by