categorical

Methods

Method Reference: categorical.isordinal

categorical: TF = isordinal (C)

Test if categorical array is ordinal.

TF = isordinal (C) returns a logical scalar TF, which is true, if the categorical array C is ordinal, and false otherwise.

Source Code: categorical

Example: 1

isordinal reports whether the categories carry an order. A plain array is nominal — its categories are just labels with no ranking ...

 N = categorical ({'red'; 'green'; 'blue'})
N =
  3x1 categorical array

    red      
    green    
    blue
 isordinal (N)
ans = 0

... while one built with 'Ordinal', true is ordered, which is what lets it be compared with < and > and sorted meaningfully.

 O = categorical ({'lo'; 'hi'; 'mid'}, {'lo', 'mid', 'hi'}, 'Ordinal', true)
O =
  3x1 categorical array

    lo     
    hi     
    mid
 isordinal (O)
ans = 1