Rank the entries of a matrix with codes.
    3 views (last 30 days)
  
       Show older comments
    
    Wan-Yi Chiu
 on 16 May 2023
  
    
    
    
    
    Answered: Walter Roberson
      
      
 on 16 May 2023
            Load a matrix:
[12 4 6; 
7 3 8; 
1 6 5;
 9 2 5]
How to rank each row relative to columns with codes as:
3  1  2
2  1  3
1  3  2
3  1  2
Thank you very much.
0 Comments
Accepted Answer
  Walter Roberson
      
      
 on 16 May 2023
        A = [12 4 6; 
7 3 8; 
1 6 5;
 9 2 5]
[~, idx] = sort(A, 2)
[~, rank] = sort(idx, 2)
0 Comments
More Answers (0)
See Also
Categories
				Find more on Interpolation 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!