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

    %% Add Categories and Specify Category to Precede  

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

%% 
% Display the categories of |A|. 
categories(A) 

%%
% Since |A| is ordinal, the categories have the mathematical ordering |small
% < medium < large < xlarge|.  

%% 
% Add the category |xsmall| before |small|. 
B = addcats(A,'xsmall','Before','small') 

%%
% |B| contains the same values as |A|.  

%% 
% Display the categories of |B|. 
categories(B) 

%%
% The categories have the mathematical ordering |xsmall < small < medium
% < large < xlarge|.