Accessing Fit Coefficients from Curve Fitting
29 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
the cyclist
2024-6-9
data_fit is a cfit object. You can apply post-processsing steps to this object, as described in this documentation.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!