Reputation: 217
Let's say I have an array A = [ 41 13 22 18 32]
How can I get the indexes of the three greatest values?
In this example I expect to get 1,5,3 (indexes of 41,32,22).
Thanks!
Upvotes: 0
Views: 520
Reputation: 680
According to this documentation:
A = [ 41 13 22 18 32];
[val idx]=sort(A,'descend');
top3_idx=idx(1:3)
It works in Octave online
Upvotes: 4