Compare Categorical Array Elements
This example shows how to use relational operations with a categorical array.Create Categorical Array from Cell Array of Character VectorsCreate a 2-by-4 cell array of character vectors.C = {'blue' 'red' 'green' 'blue';...
'blue' 'green' 'green' 'blue'};colors = categorical(C)colors = 2x4 categorical array
blue red green blue
blue green green bluecolors is a 2-by-4 categorical array.List the categories of the categorical array.categories(colors)ans = 3x1 cell array
{'blue' }
{'green'}
{'red' }Determine If Elements Are EqualUse the relational operator, eq (==), to compare the first and second rows of colors.colors(1,:) == colors(2,:)ans = 1x4 logical array1 0 1 1Only the values in the second column differ between the rows.8 Categorical Arrays