필터 지우기
필터 지우기

Rank the entries of a matrix with codes.

조회 수: 1 (최근 30일)
Wan-Yi Chiu
Wan-Yi Chiu 2023년 5월 16일
답변: Walter Roberson 2023년 5월 16일
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.

채택된 답변

Walter Roberson
Walter Roberson 2023년 5월 16일
A = [12 4 6;
7 3 8;
1 6 5;
9 2 5]
A = 4×3
12 4 6 7 3 8 1 6 5 9 2 5
[~, idx] = sort(A, 2)
idx = 4×3
2 3 1 2 1 3 1 3 2 2 3 1
[~, rank] = sort(idx, 2)
rank = 4×3
3 1 2 2 1 3 1 3 2 3 1 2

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by