Fit data to Gaussian distribution I want some data to fit the corresponding Gaussian distribution.

The data is meant to be Gaussian already, but for some filtering reasons, they will not perfectly match the prescribed and expected Gaussian distribution. I therefore aim to reduce the existing scatter between data and desired distribution.

For example, my data fit the Gaussian distribution as follows:





The approximation is already decent, but I really want to crunch the still tangible scatter between simulated data and expected distribution.

How can I achieve this?
The least-squares fitting is probably what your are looking for as this is maximum likelihood estimator for data points with Gaussian distribution around best fit curve.

There is already a built-in function lsqcurvefit in MATLAB:

I wrote a tutorial article on both linear and non-linear least squares methods (Gauss-Newton, Levenberg-Marquardt) if you need some deeper understanding of the topic:

Linear and Nonlinear Least-Squares with Math.NET



Please note you are asking how to use some actual piece of software (i.e. MATLAB) while this site is more about principles and practices. You can find hints for MATLAB on other forum (e.g. StackOverflow).