필터 지우기
필터 지우기

Assign rank to matrix and compare it

조회 수: 1 (최근 30일)
Paulus Soenarjo
Paulus Soenarjo 2019년 5월 2일
댓글: Paulus Soenarjo 2019년 5월 5일
I want to be able to assign a rank to numbers in matrix, let say the matrix has 3 variable random static data. let's say i want to ranked the data from 1 to 5, from top to the bottom (not sort it), For example:
Name = {'Fred';'Betty';'Bob';'George';'Jane'};
Age = [38;43;38;40;38];
Height = [71;69;64;67;64];
Weight = [176;163;131;185;131];
A = table(Age,Height,Weight,'RowNames',Name)
the question:
1.How to assign the rank in the matrix like in the picture above?
2. How to compare the result? let's say i want compare Fred and Bob, i want the final result is Fred because according to the rank order he is rank 1.
Thanks

채택된 답변

KSSV
KSSV 2019년 5월 2일
Name = {'Fred';'Betty';'Bob';'George';'Jane'};
Age = [38;43;38;40;38];
Height = [71;69;64;67;64];
Weight = [176;163;131;185;131];
A = table(Age,Height,Weight,'RowNames',Name) ;
Rank = (1:5)' ;
R = table(Rank) ;
T = [A R] ;
idx = min(T.Rank) ;
A(idx,:)
  댓글 수: 6
Paulus Soenarjo
Paulus Soenarjo 2019년 5월 2일
Matlab R2017a
Paulus Soenarjo
Paulus Soenarjo 2019년 5월 5일
ok, finally after i upgraded my matlab to R2019a it's work! thanks so much

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by