Problem with Gaussian fit to Data
显示 更早的评论
What is wrong with this Gaussian Fit:
gaussEqn = 'a*exp(-((x-b)/c)^2)+d'
f = fit(xdata.',ydata.',gaussEqn)
%Results of fit
coeffs=coeffvalues(f);
a=coeffs(1)
b=coeffs(2)
c=coeffs(3)
d=coeffs(4)
xValue=7;
sp=3;
%Create fine data to plot fit
xdataF=(linspace(xValue-sp,xValue+sp,10*sp))
fitGaus = a*exp(-((xdataF-b)/c)^2)+d
yvalue=ym;
xpeak=xdataF(find(fity==ym));
xpeak=mean(xpeak(:)); %Take mean incase more than one peak found
the fit is fine:
f =
General model:
f(x) = a*exp(-((x-b)/c)^2)+d
Coefficients (with 95% confidence bounds):
a = 0.7094
b = 0.7547
c = 0.276
d = 1482 (-1823, 4787)
But I get the error:
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
Error in HiSeqDistortionTool>fitLocalPeak (line 726)
fitGaus = a*exp(-((xdataF-b)/c)^2)+d
回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!