reordercats
Reorder the categories of a categorical array.
Syntax
Section titled “Syntax”B = reordercats(A)B = reordercats(A, neworder)Description
Section titled “Description”Returns A with categories in a new order. With one argument, sorts alphabetically. With neworder (a cell array of category names in the desired order), uses that order. Especially relevant for ordinal arrays where order has semantic meaning.
Example
Section titled “Example”reordercats(categorical({'b','a','c'}), {'c','b','a'})See also
Section titled “See also”categorical— Create a categorical array from data.isordinal— Test whether the categorical array is ordinal.