B = reordercats(A)
B = reordercats(A, newOrder)
| Parameter | Description |
|---|---|
| A | Input categorical array. |
| newOrder | New category order, specified by category names or numeric positions. |
| Parameter | Description |
|---|---|
| B | Categorical array with the same displayed values as A and a reordered category list. |
reordercats changes the order of categories. If newOrder is omitted, categories are sorted by name.
For ordinal arrays, the new category order changes relational comparisons and sorting order.
A = categorical({'red','blue'}, {'red','blue'}); B = reordercats(A, {'blue','red'}); categories(B)
A = categorical({'plane','car','train'}); B = reordercats(A); categories(B)
| Version | Description |
|---|---|
| 2.0.0 | initial version |