www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/FindValuesInCategoricalArrayExample.m

    %% Find Values in Categorical Array
% Create a categorical array with two values: |'heads'| and |'tails'|.

% Copyright 2015 The MathWorks, Inc.

A = categorical({'heads' 'heads' 'tails'; 'tails' 'heads' 'tails'})

%%
% Find all values in the |'heads'| category.
A == 'heads'

%%
% A value of logical |1| (|true|) indicates a value in the category.

%%
% Compare the rows of |A| for equality.
A(1,:) == A(2,:)

%%
% A value of logical |1| (|true|) indicates where the rows have equal
% category values.