Sort categorical variables in an alphabetical order
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
alpedhuez
am 12 Dez. 2020
Kommentiert: alpedhuez
am 12 Dez. 2020
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 Kommentare
Ive J
am 12 Dez. 2020
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'}
Akzeptierte Antwort
Rik
am 12 Dez. 2020
As Ive Ive suggested: the sort function will do what you need:
B = categorical({'NY','Boston'});
sort(B)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!