find index of last 5 largest values in cell array
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gopalakrishnan venkatesan
am 24 Aug. 2015
Kommentiert: Star Strider
am 24 Aug. 2015
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 Kommentare
Akzeptierte Antwort
Star Strider
am 24 Aug. 2015
This works:
[as,idx] = sort(cell2mat(a),'descend');
result = idx(1:5);
2 Kommentare
Star Strider
am 24 Aug. 2015
My pleasure.
The unique function works for the second problem:
[C,idx] = unique(cell2mat(a));
result = idx(end-4:end);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!