Sorting a Cell Array based in multiple dimenssion
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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
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
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])
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Frequently-used Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!