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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by