find index of last 5 largest values in cell array
3 ビュー (過去 30 日間)
古いコメントを表示
Gopalakrishnan venkatesan
2015 年 8 月 24 日
コメント済み: Star Strider
2015 年 8 月 24 日
I have a cell array of numbers a = {5 ; 6 ; 8 ; 8 ; 10; 1 ; 15 ; 25 ; 10 ; 35 ; 45 ; 3}
I need to find the index of last five largest values in cell array
index = 11,10,8,7,5
How can i do this ?
Thanks a lot
0 件のコメント
採用された回答
Star Strider
2015 年 8 月 24 日
This works:
[as,idx] = sort(cell2mat(a),'descend');
result = idx(1:5);
2 件のコメント
Star Strider
2015 年 8 月 24 日
My pleasure.
The unique function works for the second problem:
[C,idx] = unique(cell2mat(a));
result = idx(end-4:end);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!