First 5 minimum elements of a vector

19 次查看(过去 30 天)
I found the minimum element of vector by
[m index]=min(vector);
How to find first five minimum elements of a vector and its index??

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-2-7
编辑:Azzi Abdelmalek 2013-2-7
vector=rand(10,1)
[x,idx]=sort(vector)
out_x=x(1:5) % 5 first values
out_idx=idx(1:5) % corresponding indices
  1 个评论
Amir Hosein Fardi
Amir Hosein Fardi 2021-11-23
that was really helpful
after 5 yrs of matlab programming today I was thinking about it and I really got confused to find the proper way to do that .

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by