Sort categorical variables in an alphabetical order
1 回表示 (過去 30 日間)
古いコメントを表示
I have a set of categorical variables
A = {'NY','Boston'}
How can one sort A to B as
B = {'Boston','NY'}
I tried sort but does not work.
2 件のコメント
Ive J
2020 年 12 月 12 日
This is very sruprising that sort doesn't work for you (I'm wondering how is this even possible).
A = {'NY', 'Boston'};
sort(A)
1×2 cell array
{'Boston'} {'NY'}
採用された回答
Rik
2020 年 12 月 12 日
As Ive Ive suggested: the sort function will do what you need:
B = categorical({'NY','Boston'});
sort(B)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および 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!