www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CompareValuesInCategoricalArrayLessThanOrEqualExample.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 less than or equal to the category |'medium'|. 
A <= 'medium' 

%%
% A value of logical |1| (|true|) indicates a value less 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 less than or equal to the second row.