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

    %% Compare Values in Categorical Array  

%% 
% Create an ordinal categorical array. 
A = categorical({'large' 'medium' 'small'; 'medium' ...
'small' 'large'},{'small' 'medium' 'large'},'Ordinal',1) 

%%
% The array has three categories: |'small'|, |'medium'|, and |'large'|.  

%% 
% Find all values greater than or equal to the category |'medium'|. 
A >= 'medium' 

%%
% A value of logical |1| (|true|) indicates a value greater than or equal
% to the category |'medium'|.

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

%%
% The function returns logical |1| (|true|) where the first row has a
% category value greater than or equal to the second row.