I want to find the smallest 5 values in an integer vector of 10 integers. Not only the values but also their indices. Can anyone guide me please?
for example v = [0 5 1 3 2 6 0 9 8 7]
the answer should be [0 0 1 2 3] and their indices.
Thank you

 채택된 답변

James Tursa
James Tursa 2011년 6월 15일

1 개 추천

See the 2nd output of the sort function giving the original indexes of the sorted values.
[B,IX] = sort(A,...)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

질문:

2011년 6월 15일

댓글:

2018년 1월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by