Sorting columns of cell Array

6 ビュー (過去 30 日間)
Manuel Arcangeletti
Manuel Arcangeletti 2019 年 5 月 13 日
編集済み: Stephen23 2019 年 5 月 13 日
Hello,
I have a Cell Array of Data that is 144x12; it looks like this:
Cell Array_snapshot.png
Now I would like to sort the columns by the value in row 7. At the end, what I would like is a Cell Array with the first column that has in row 7 'p1' and so on...
I will try to be more specific because maybe there's a clever way to obtain what I need...
In my data there are, for example, six columns that have the same value in row 7, but different values in row 6. Given that, I need to do some analysis on all the ones that have the same value in row 7, but taking as reference the one between them that have a certain value in row 6.
Can somebody help me please?
Thank you very much and best regards,
Manuel

採用された回答

Stephen23
Stephen23 2019 年 5 月 13 日
編集済み: Stephen23 2019 年 5 月 13 日
Either download my FEX submission natsort:
and then use it like this, where C is your cell array:
[~,idx] = natsort(C(7,:))
D = C(:,idx)
Or use sscanf to get the numeric values and then sort them:
[~,idx] = sort(sscanf([C{7,:}],'p%f'))
D = C(:,idx)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by