필터 지우기
필터 지우기

rank the values in each row

조회 수: 1 (최근 30일)
Qian cao
Qian cao 2016년 2월 4일
댓글: Qian cao 2016년 2월 5일
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
Stephen23
Stephen23 2016년 2월 5일
편집: Stephen23 2016년 2월 5일
@Qian cao: Please explain why row three is
2 1 2 4
and not
2 1 2 3
Qian cao
Qian cao 2016년 2월 5일
Hi, This is an exercise given by our teacher. He said when there are 2 equal values, the rank of the next value larger than them will be +2 instead of +1.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 2월 4일
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
Stephen23
Stephen23 2016년 2월 4일
편집: Stephen23 2016년 2월 4일
Using uniquetol to do this would be more robust.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by