reorderlevels

(Not Recommended) Reorder levels of nominal or ordinal arrays

The nominal and ordinal array data types are not recommended. To represent ordered and unordered discrete, nonnumeric data, use the Categorical Arrays (MATLAB) data type instead.

Description

B = reorderlevels(A,newlevels) returns a nominal or ordinal array object of the same type as A, but with levels in the new order specified by newlevels.

For ordinal arrays, the order of the levels has significance for relational operators, finding minimum and maximum values, and sorting.

Input Arguments

collapse all

Nominal or ordinal array, specified as a nominal or ordinal array object created with nominal or ordinal.

New order of levels, specified as a string array, cell array of character vectors, or 2-D character matrix. newlevels must be a reordering of the labels returned by getlabels.

Data Types: char | string | cell

Output Arguments

collapse all

Nominal or ordinal array, returned as a nominal or ordinal array object.

Introduced in R2007a