www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/RenameOneCategoryExample.m
%% Rename One Category %% % Create a categorical array containing colors. A = categorical({'red' 'blue'; 'purple' 'white'; 'green' 'red'}) %% % |A| is a 3-by-2 categorical array. %% % Display the categories of |A|. categories(A) %% % |A| has five categories that are listed in alphabetical order. %% % Change the category name from |purple| to |violet|. B = renamecats(A,'purple','violet') %% % The element |B(2,1)| is |violet| instead of |purple|. %% % Display the categories of |B|. categories(B) %% % |violet| replaces |purple| and the categories are no longer in alphabetical % order. Note that the category has not changed its position.