Sorting a Cell Array based in multiple dimenssion

조회 수: 1 (최근 30일)
alexis
alexis 2012년 8월 29일
Dear all, I have a broblem with my Cell Array. I tried to use this function http://www.mathworks.com/help/toolbox/stats/dataset.sortrows.html but didn't work to me.. I have this cell array :
YPL-320 'SMITH' Male 38
GLI-532 'JOHNSON' Male 43
PNI-258 'WILLIAMS' Female 38
MIJ-579 'JONES' Female 40
XLK-030 'BROWN' Female 49
I would like to sort it based on 2th and 4th column:
REV-997 'ALEXANDER' Male 25
FZR-250 'HALL' Male 25
LIM-480 'HILL' Female 25
XUE-826 'JACKSON' Male 25
SCQ-914 'JAMES' Male 25
How can I do this?
Thanks & BRgds
  댓글 수: 2
Matt Fig
Matt Fig 2012년 8월 29일
Nothing about the second array is the same as the first! You don't show a sorted cell array, you show a different cell array....
Jan
Jan 2012년 8월 29일
@Matt: Alexis shows the first 5 lines of the unsorted and the sorted array, while she hides the other 162 lines to improve the readability of the question.
We had a serious problem with our patient database, when a participator of a long term study changed his (or her?) sex. Of course the strict specifications of a clinical double blind study do not allow to modify the software such that the one or other patient can be included. Perhaps this would explain the 'Female' to 'Male' switch in the data.

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

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 8월 29일
B = { 'YPL-320' 'SMITH' 'Male' 38
'GLI-532' 'JOHNSON' 'Male' 43
'PNI-258' 'WILLIAMS' 'Female' 38
'MIJ-579' 'JONES' 'Female' 40
'XLK-030' 'BROWN' 'Female' 49}
sortrows(B,[2 4])

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by