Gaussian fiting
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have (X,Y) data and i want to fit this data with a Gaussian. Basically i use 'lsqnonlin' which works fine (if the initial solution X0 is not too bad).
I just have two questions because i don't have a lot of experience with Matlab:
1/ lsqnonlin seems to be an appropriate method (Gaussian = non linear (mu,sigma)) but i find a tool in mathwork which use polyfit ? Do you think Polyfit or other methods would be better than lsqnonlin (regarding to the stability of the final solution and the importance of the initial solution).
2/ I use the folowing definition for Gaussian :
G = A * 1/(sigma*sqrt(2*pi)) * exp(-(1/2)*(X-mu/sigma).^2) + C;
A,mu sigma and C are the variable to estimate.
This allow me to obtain sigma directly. Do you think it's the best way to "express" the Gaussian ?
Thank you very much for your help
0 Kommentare
Akzeptierte Antwort
Andrew Newell
am 4 Apr. 2011
1. Polyfit wouldn't make much sense because a Gaussian is not polynomial and would be badly approximated by polynomials.
2. The normalizer is irrelevant because you are multiplying it by some unknown. Also, since mu is the mean (and therefore determines the horizontal displacement), you could get rid of C. However, you need an extra pair of parentheses:
G = A * exp(-(1/2)*((X-mu)/sigma).^2);
Or you could get rid of mu and keep C:
G = A * exp(-(1/2)*(X/sigma).^2) + C;
Either way, you now only have 3 parameters to fit.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Polynomials finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!