For Programmers: Free Programming Magazines  


Home > Archive > Matlab > December 2005 > Top n list









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Top n list
berniecr@clarkson.edu

2005-12-17, 7:05 pm

i need a function that returns the indexes of the top n highest values
in a vector.

example:

a=[1 2 3 2 3 5 7 8 9 21 55 23 12 78 15]

b=top(a,5)

b=[14 11 12 10 15]

the order of b does not matter

us

2005-12-17, 7:05 pm

berniecr@clarkson.edu:
<SNIP sorting-indices evergreen...

one of the solutions

a=[1 2 3 2 3 5 7 8 9 21 55 23 12 78 15];
[as,ax]=sort(a,'descend');
r=ax(1:5)

us
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com