I want to be able to assign a rank to numbers in a vector depending on their size and make a new vector containing these ranks.
For instance, if I have the vector [5, 2, 3, 1]
, I want to return [4, 2, 3, 1]
(as 5 is the largest number and 1 is the smallest). Equal numbers should share an average rank preferably (for instance, if both are the same and are the lowest, they should get an average rank of 1.5).
How can I achieve this in MATLAB?