Main Content

Nominal and Ordinal Arrays

Note

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

What Are Nominal and Ordinal Arrays?

Nominal and ordinal arraysare 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.

  • ordinalarrays store categorical values with ordered levels. For example, an ordinal variable might have levels {small, medium, large}.

  • nominalarrays store categorical values with unordered levels. For example, a nominal variable might have levels {red, blue, green}.

In experimental design, these variables are often calledfactors, with ordered or unorderedfactor 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.

Nominal and Ordinal Array Conversion

You can easily convert to and from nominal or ordinal arrays. To create a nominal or ordinal array, usenominalorordinal, 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

See Also

|

Related Examples

More About