www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CreateAndManipulateNominalArraysExample.m
%% Create and Manipulate Nominal Arrays %% % Create a nominal array from data in a cell array. colors = nominal({'r','b','g';'g','r','b';'b','r','g'},... {'blue','green','red'}) %% % Identify the elements in |colors| that are members of the level |'red'|. % A value of |1| in the resulting array indicates that the corresponding % element of |colors| is a member of |'red'|. colors == 'red' %% % Identify the elements of |colors| that are members of either |'red'| or % |'blue'|. ismember(colors,{'red' 'blue'}) %% % Merge the elements of the |'red'| and |'blue'| levels into a new % level labeled |'purple'|. colors = mergelevels(colors,{'red','blue'},'purple') %% % Display the levels of |colors|. getlevels(colors) %% % Summarize the number of elements in each level. By default, |summary| % returns counts for each column of the input array. summary(colors) %% % Create a pie chart for the data in |colors|. pie(colors)