%% Create Ordinal Categorical Array
% Create a 5-by-2 numeric array.

A = [3 2;3 3;3 2;2 1;3 2]

%
% Convert A to an ordinal categorical array where 1, 2, and 3 represent categories child, adult, and senior respectively.

valueset = [1:3];
catnames = {'child' 'adult' 'senior'};

B = categorical(A,valueset,catnames,'Ordinal',true)

% Since B is ordinal, the categories of B have a mathematical ordering, child < adult < senior.
% Copyright 2012 The MathWorks, Inc.