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

    %% Specify Bin Edges of Histogram
% Generate 1,000 random numbers and create a histogram. Specify the bin
% edges as a vector with wide bins on the edges of the histogram to capture
% the outliers that do not satisfy $|x|<2$. The first vector element is the
% left edge of the first bin, and the last vector element is the right edge
% of the last bin.

% Copyright 2015 The MathWorks, Inc.

x = randn(1000,1);
edges = [-10 -2:0.25:2 10];
h = histogram(x,edges);

%%
% Specify the |Normalization| property as |'countdensity'| to flatten out
% the bins containing the outliers. Now, the _area_ of each bin (rather
% than the height) represents the frequency of observations in that
% interval.
h.Normalization = 'countdensity';