Problem with Gaussian fit to Data
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!