%% Specify Category Names for Integers
% Create a numeric array.

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

%
% Convert A to categorical array B and specify category names.

B = categorical(A,[1 2 3],{'red' 'green' 'blue'})

%
% Display the categories of B.

categories(B)

%
% B is not an ordinal categorical array. Therefore, you can compare the values in B only using the equality operators, == and ~=.
% Find the elements that belong to the category 'red'. Access those elements using logical indexing.

TF = (B == 'red');
B(TF)

%
% Copyright 2012 The MathWorks, Inc.