Sort categorical variables in an alphabetical order
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
alpedhuez
el 12 de Dic. de 2020
Comentada: alpedhuez
el 12 de Dic. de 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 comentarios
Ive J
el 12 de Dic. de 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'}
Respuesta aceptada
Rik
el 12 de Dic. de 2020
As Ive Ive suggested: the sort function will do what you need:
B = categorical({'NY','Boston'});
sort(B)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!