MATLAB Answers

tiedrank in descending order?

14 views (last 30 days)
Is there any way to use tiedrank in descending order? I need to rank the highest value as the smallest one in rank. Is it possible to do this using tiedrank or another built-in-function? Thank you~~

  1 Comment

Peter Dodds
Peter Dodds on 7 Apr 2019
To do this in one line, just negate the vector. For example:
>> counts = [23, 1, 17, 95, 133];
>> ranks = tiedrank(-counts);
>> ranks
ranks =
3 5 4 2 1

Sign in to comment.

Accepted Answer

Sid Jhaveri
Sid Jhaveri on 2 Mar 2017
Hi Ekin,
You can the reverse the order of ranking programmatically as follows:
%Store the result of tiredrank function in "a"
a = tiedrank([10 20 30 40 20]);
%Find the largest rank value of "a", increment it by 1 and subtract "a" by
%this value.
ranks_desc = (max(a)+1) - a;
This will just reverse the ranking received by "tiedrank" function.

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.