MATLAB: Location of 10 highest values

maximumvalues

Hi all, I have a 1×34 matrix. I want to find the location of the 10 largest values. So the output should be 1×10 and have values like 2,3,6 etc……
Thank you.

Best Answer

[bigvalues, bigidx] = sort(YourMatrix, 'descend');
bigidx(1:10)
However, this is not suitable if your values might not be unique. Also, if your values might include NaN then you need to decide whether for your purpose NaN are high or not.