Superimposing a user defined function on a histogram
Show older comments
Here is my attempt where the hist is bar(I,Y) and I want to superimpose Gaussian onto it
Z=[2 3 0 6 0 9 4 0]; N=sum(Z); M=sum(Z(6:8)); m=M; O=sqrt(N); Y=randn(10000,1)*O + m; x=mean(Y); s=std(Y); E=(abs(m-x)/m)*100; PE=(abs(O-s)/O)*100; Y=hist(Y,10000)/10000; Y=Y'; I=linspace(m-3*O,m+3*O,10000); bar(I,Y); hold on plot(I,Gaussian(x,m,O))
Here is the function
function [ gauss e u ] = Gaussian(x,m,O) %This is the Gaussian function % using variables x, m, and o d=1/sqrt(2*pi); e=2*O^2; u=(x-m)^2; gauss=(d*(O^(-1)))^(-u/e);
3 Comments
Image Analyst
on 23 Nov 2012
Do you have a question?
Chris
on 23 Nov 2012
Chris
on 23 Nov 2012
Answers (0)
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!