Note
The nominal
and ordinal
array data types are not recommended. To represent ordered and unordered discrete, nonnumeric
data, use the Categorical Arrays data type instead.
Nominal and ordinal arrays are Statistics and Machine Learning Toolbox™ data types for storing categorical values. Nominal and ordinal arrays store data that have a finite set of discrete levels, which might or might not have a natural order.
ordinal
arrays store categorical values with
ordered levels. For example, an ordinal variable might have levels
{small, medium, large}.
nominal
arrays store categorical values with
unordered levels. For example, a nominal variable might have levels
{red, blue, green}.
In experimental design, these variables are often called factors, with ordered or unordered factor levels.
Nominal and ordinal arrays are convenient and memory efficient containers for storing categorical variables. In addition to storing information about which category each observation belongs to, nominal and ordinal arrays store descriptive metadata including category labels and order.
Nominal and ordinal arrays have associated methods that streamline common tasks such as merging categories, adding or dropping levels, and changing level labels.
You can easily convert to and from nominal or ordinal arrays. To create a nominal
or ordinal array, use nominal
or ordinal
,
respectively. You can convert these data types to nominal or ordinal arrays:
Numeric arrays
Logical arrays
Character arrays
String arrays
Cell arrays of character vectors