Superimposing a user defined function on a histogram
Afficher commentaires plus anciens
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 commentaires
Image Analyst
le 23 Nov 2012
Do you have a question?
Chris
le 23 Nov 2012
Chris
le 23 Nov 2012
Réponses (0)
Catégories
En savoir plus sur Histograms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!