MATLAB: Finding the top ten values of arrary

data

Hello, I have an array a,i want to find the top ten max values and thier indexes , how i can do that , Thanks ?

Best Answer

Try this:
M = magic(4);
N = 10;
[ b, ix ] = sort( M(:), 'descend' );
[ rr, cc ] = ind2sub( size(M), ix(1:N) );
for ii = 1 : N
disp( M( rr(ii), cc(ii) ) )
end