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 ExchangeResizing 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