i have cell array and want to sort it based on 2nd column .
i have tried this
[~,idx] = sort([AA{:,2}]);
idx([1:2:end,2:2:end]) = idx;
B = AA(idx,:);
but 2nd column in not in descending order .

 採用された回答

Adam Danz
Adam Danz 2019 年 3 月 26 日
編集済み: Adam Danz 2019 年 3 月 26 日

0 投票

The [65 x 2] cell array in your mat file is named "A1".
[~, idx] = sort([A1{:,2}], 'descend');
A1_descendingOrder = A1(idx,:)

2 件のコメント

jahanzaib ahmad
jahanzaib ahmad 2019 年 3 月 26 日
thank you very much
Adam Danz
Adam Danz 2019 年 3 月 26 日
You were so close!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File 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