Filter löschen
Filter löschen

Accessing Fit Coefficients from Curve Fitting

3 Ansichten (letzte 30 Tage)
Elias
Elias am 9 Jun. 2024
Kommentiert: Elias am 10 Jun. 2024
Hello, I am attempting to generate a graph of the full width half max (FWHM) of multiple sets of data but want to first fit each dataset to a Gaussian. Currently, I am calculating the FWHM by indexing the first and last instances of the half-max value for each dataset, then graphing all of these values. This works alright; however, I would like to improve upon this by fitting each dataset to a Gaussian distribution and then use the calculated Gaussian coefficients from the fitting in order to find the FWHM, as this would be more accurate. I have been able to fit each dataset to a Gaussian using the fit() function. However, I have run into an issue where I seem to be unable to access the generated Gaussian coefficients, which are what I need in order to be able to recalculate the FWHM. Does anyone know how I might be able to access these coefficients or generate them in such a way that I would be able to access them? Below I have copied the portion of my code where I am fitting the data along with a screenshot of the particular math I am referring to using the Gaussian coefficients to calculate the FWHM. Thank you so much!
y_fit = data.'; % turns data into a variable for fit, transposes to column
l_y = length(y_fit); % generates a variable with the length of y_fit
x_fit = linspace(0,l_y,l_y).'; % creates a column variable simply for the x-axis
data_fit = fit(x_fit,y_fit,'gauss1'); % this creates a fitted data set

Akzeptierte Antwort

the cyclist
the cyclist am 9 Jun. 2024
data_fit is a cfit object. You can apply post-processsing steps to this object, as described in this documentation.
It sounds like you specifically need the coeffvalues function.
  1 Kommentar
Elias
Elias am 10 Jun. 2024
This is exactly what I need thank you so much for pointing me the right direction!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by