www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/PlotCategoricalHistogramExample.m
%% Plot Categorical Histogram % Create a categorical vector that represents votes. The categories in the % vector are |'yes'|, |'no'|, or |'undecided'|. % Copyright 2015 The MathWorks, Inc. A = [0 0 1 1 1 0 0 0 0 NaN NaN 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1]; C = categorical(A,[1 0 NaN],{'yes','no','undecided'}) %% % Plot a categorical histogram of the votes, using a relative bar width of % |0.5|. h = histogram(C,'BarWidth',0.5)