rank the values in each row
1 view (last 30 days)
Show older comments
Hi all, If I have a matrix like
A=
0.2 NaN 0.8 0.8
-0.2 1 0.3 0.2
0.2 -0.3 0.2 2
0.7 -0.1 -0.4 0.7
NaN 0.2 NaN 0.9
How do I get a resulting matrix B which ranks each row of A and the result shows like this ... Pay attention to row 3. Thank you for your answer.I am playing around some tricks in Matlab and looking for a best solution to problems as this one...
B=
1 NaN 2 2
1 4 3 2
2 1 2 4
3 2 1 3
NaN 1 NaN 2
2 Comments
Answers (1)
Walter Roberson
on 4 Feb 2016
Loop through the rows. For any one row, you can use the third output of unique as the index, except that you would have to replace the entries corresponding to NaN.
1 Comment
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!