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

    %% Handle for a Histogram with a Distribution Fit   

% Copyright 2015 The MathWorks, Inc.


%% 
% Generate a sample of size 100 from a normal distribution with mean 10
% and variance 1. 
rng default % for reproducibility
r = normrnd(10,1,100,1);  

%% 
% Construct a histogram with a normal distribution fit. 
h = histfit(r,10,'normal')  

%% 
% Change the bar colors of the histogram. 
h(1).FaceColor = [.8 .8 1];

%% 
% Change the color of the density curve. 
h(2).Color = [.2 .2 .2];