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

    %% Specify Histogram Axes  

% Copyright 2015 The MathWorks, Inc.


%% 
% Create a figure with two subplots. In the upper subplot, plot a histogram of 1,000 random numbers
% sorted into 50 equally spaced bins. In the lower subplot, plot a
% histogram of the same data and use bins with centers at -3, 0, and 3.

x = randn(1000,1);
ax1 = subplot(2,1,1); 
hist(ax1,x,50)

ax2 = subplot(2,1,2);
xbins = [-3 0 3];
hist(ax2,x,xbins)