MATLAB: Fit a histogramm to a gaussian- or vice versa

gaussianhistogram

Hello folks.
After making a histogramm, i want to compare it with the bell curve. But i have difficulties to manage a fit.
For calculating the bell curve i'm using this function:
function f = gauss_distribution(x, mu, s)
p1 = -.5 * ((x - mu)/s) .^ 2;
p2 = (s * sqrt(2*pi));
f = exp(p1) ./ p2;
What can i do to make them fit? I'm really frustrated right now. Is there a good way?
Greetings

Best Answer

One thing you'll need to do is to scale the histogram and bell curve so they have the same area. See my answer to this question:
Related Question