MATLAB: How to give ranking from highest to lowest Control System Toolboxranking elements Hello, I have number like Data=[5 6 9 1 5 2] I want to rank them as: [3 2 1 6 4 5] Can any please help me How can I do this. Thanks in advance. Best Answer This should give you the rank you are asking for, Mekala: [~,p] = sort(Data,'descend'); r = 1:length(Data); r(p) = r;'r' will be the ranking. Related SolutionsMATLAB: Union of cell matrix unique(cell2mat(A)) MATLAB: Ranking of an array. I assume, the result should be [2 4; 5 6; 3 1] with the last two elements swapped. The method is called sorting, not ranking.M = [1,5; 7 9; 2 0];[dummy, index] = sort(M(:));R(index) = 1:numel(M);R = reshape(R, size(M)); Related QuestionHow to sort/Rearrange a matrixSort and assign rankingSortrows
Best Answer