Gaussian fit to xy data and extracting FWHM

조회 수: 250 (최근 30일)
Matlab User
Matlab User 2020년 1월 8일
답변: Fynn Reinbacher 2020년 11월 5일
Hello,
I am hoping someone could help. I am going round in circles although i'm sure it's a straightforward answer.
I have an xy data set (see attached for example). I want to fit a gaussian to this, from which the FWHM of the gaussian and the goodness of fit extracted (those that do not have good gaussian fits will be then rejected on the basis of r squared values.
I tried using cftool, and from what i have read, I can use FWHM= 2*sqrt(2*log(2))*c1 to get the FWHM. But the value I get (~30), doesn't match up to what i expect from looking at the curve at the half-maximum (~20).
Picture 1.png
Thankyou

채택된 답변

Daniel M
Daniel M 2020년 1월 8일
This is because of the slightly different way cftool has defined the gaussian equation for the fit, and it ends up multipling the c1 coefficient by a factor of sqrt(2) from the true value of the standard deviation.
The equation for FWHM is
FWHM = 2*sqrt(2*log(2))*sigma
%%% sigma, NOT c1!
For fitting, MATLAB uses
f(x) = a1*exp(-((x-b1)/c1)^2)
And wherever you're reading the FWHM equation defined the gaussian as
f(x) = (1/sigma/sqrt(2*pi))*exp(-(x-mu)^2/(2*sigma^2))
By equating the two, you'll find that
sigma = c1/sqrt(2)
Therefore the FWHM equation becomes
FWHM = 2*sqrt(2*log(2)) * (c1/sqrt(2))
FWHM = 2*sqrt(log(2)) * c1
And in fact, when you use this new equation, you get FWHM = 21.78, which is accurate.

추가 답변 (1개)

Fynn Reinbacher
Fynn Reinbacher 2020년 11월 5일

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by