find index of last 5 largest values in cell array
조회 수: 3 (최근 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!