find index of last 5 largest values in cell array
2 次查看(过去 30 天)
显示 更早的评论
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!