Effacer les filtres
Effacer les filtres

Accessing Fit Coefficients from Curve Fitting

3 vues (au cours des 30 derniers jours)
Elias
Elias le 9 Juin 2024
Commenté : Elias le 10 Juin 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

Réponse acceptée

the cyclist
the cyclist le 9 Juin 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 commentaire
Elias
Elias le 10 Juin 2024
This is exactly what I need thank you so much for pointing me the right direction!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by