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

    %% Fit a Normal Distribution to Data  

% Copyright 2015 The MathWorks, Inc.


%% 
% Load the sample data. Create a vector containing the patients' weight data. 
load hospital
x = hospital.Weight;  

%% 
% Create a normal distribution object by fitting it to the data. 
pd = fitdist(x,'Normal')  

%% 
% Plot the pdf of the distribution. 
x_values = 50:1:250;
y = pdf(pd,x_values);
plot(x_values,y,'LineWidth',2)