Main Content

reorderlevels

(Not Recommended) Reorder levels of nominal or ordinal arrays

Thenominalandordinalarray data types are not recommended. To represent ordered and unordered discrete, nonnumeric data, use theCategorical Arraysdata type instead.

Description

B= reorderlevels(A,newlevels)返回一个nominalorordinalarray object of the same type asA, but with levels in the new order specified bynewlevels.

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 anominalorordinalarray object created withnominalorordinal.

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

Data Types:char|string|cell

Output Arguments

collapse all

Nominal or ordinal array, returned as anominalorordinalarray object.

Version History

Introduced in R2007a