Rank the entries of a matrix with codes.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2023-5-16
A = [12 4 6;
7 3 8;
1 6 5;
9 2 5]
[~, idx] = sort(A, 2)
[~, rank] = sort(idx, 2)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!