First 5 minimum elements of a vector
조회 수: 16 (최근 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
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
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 Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!