www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/SpecifyBinIntervalsExample.m
%% Specify Histogram Bin Intervals % Copyright 2015 The MathWorks, Inc. %% % Plot three histograms of the same data using different bin intervals: % % * In the upper subplot, specify the bin centers using a vector of evenly % spaced values that span the values in |x|. % * In the middle subplot, specify the bin centers using a vector of evenly % spaced values that do not span the values in |x|. The first % and last bins extend to cover the minimum and maximum values in |x|. % * In the lower subplot, specify the bin intervals using a vector of unevenly % spaced values. The |hist| function uses the midpoints between consecutive % values as the bin edges and indicates the specified values by markers % along the _x_-axis. % x = randn(1000,1); subplot(3,1,1) xbins1 = -4:4; hist(x,xbins1) subplot(3,1,2) xbins2 = -2:2; hist(x,xbins2) subplot(3,1,3) xbins3 = [-4 -2.5 0 0.5 1 3]; hist(x,xbins3)