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

    %% Use hist to Calculate Only

% Copyright 2015 The MathWorks, Inc.


%% 
% Generate 1,000 random numbers.  Count how many numbers are in each of 10
% equally spaced bins. Return the bin counts and bin centers.

x = randn(1000,1);  
[counts,centers] = hist(x)  

%% 
% Use |bar| to plot the histogram. 
bar(centers,counts)