MATLAB: Fitting a lognormal curve into a histogram

histogrampdf

Hi,
I have a histogram that looks like the one below. I want to fit a lognormal curve (I think a sum of two log normal curves with different sigmas). I am not sure how to do it.
Thanks

Best Answer

% Make up some data. (You should use your real data in place of x.)
x = lognrnd(1,0.3,10000,1);
% Fit the data
parmhat = lognfit(x);
% Plot comparison of the histogram of the data, and the fit
figure
hold on
% Empirical distribution
hist(x,0.1:0.1:10);
% Fitted distribution
xt = 0.1:0.1:10;
plot(xt,1000*lognpdf(xt,parmhat(1),parmhat(2)),'r')