www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/AddCategoriesatEndExample.m
%% Add Categories at End %% % Create a nonordinal categorical array. A = categorical({'republican' 'democrat' 'republican';... 'democrat' 'republican' 'democrat'}) %% % Display the categories of |A|. categories(A) %% % |A| is a 2-by-3 categorical array with two categories. %% % Add the categories, |independent| and |undeclared|, to the end of the % category list. B = addcats(A,{'independent' 'undeclared'}) %% % |B| contains the same values as |A|. %% % Display the categories of |B|. categories(B) %% % |B| is a 2-by-3 categorical array with four categories.