Sort a table in ascending order

조회 수: 4 (최근 30일)
Shahar ben ezra
Shahar ben ezra . 2020년 11월 12일
댓글: Shahar ben ezra . 2020년 11월 12일
Hi
How can I sort a table-type array in ascending order
For example
First mode
To:
TNX :)
  댓글 수: 1
Stephen23
Stephen23 2020년 11월 12일
@Shahar ben ezra: you should transpose the way your table is arranged, otherwise it will be a nightmare to work with (both in Excel and MATLAB).

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

채택된 답변

Steve Eddins
Steve Eddins 2020년 11월 12일
편집: Steve Eddins 님. 2020년 11월 12일
The answer would be relatively straightforward, as well as much more efficient, if you would orient your table the other way. With data such as yours, table is really designed to be used this way:
>> Name = ["roni" ; "tim" ; "jon" ; "lie" ; "kim"];
>> TestScore = [90 ; 45 ; 67 ; 84 ; 32];
>> T = table(Name,TestScore)
T =
5×2 table
Name TestScore
______ _________
"roni" 90
"tim" 45
"jon" 67
"lie" 84
"kim" 32
Then you could sort the table using sortrows:
>> T2 = sortrows(T,"TestScore")
T2 =
5×2 table
Name TestScore
______ _________
"kim" 32
"tim" 45
"jon" 67
"lie" 84
"roni" 90
  댓글 수: 5
Shahar ben ezra
Shahar ben ezra 2020년 11월 12일
thanks for your help!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by