lsqcurvefit to fit data- changes with number of data points?
1 view (last 30 days)
Show older comments
Hi,
I have a weird problem. I am using lsqcurvefit as shown below. I wanted to see if removing the first few points changed the fit. Since what I am looking for isn't in that time frequency period anyways (x-axis). It seems that if I cut off 4-5 data points before fitting, my algorithm comes back with a completely different (and very visibly wrong) answer.
All data points (blue) with fit in red:
After just removing points smaller than 10^-6 I get this:
My code is below
[parameters, resnorm, residual] = ...
lsqcurvefit(@SCD, param, ...
time, autocorrelation, lowerbounds, upperbounds, options);
SCD is then function
function gD = scd(param,time)
gD = (gamma2./param(1)).*...
(1 + 8*param(2).*time./(wo.^2)).^(-1).*...
(1 + 8*param(2).*time./(z.^2)).^(-1/2) +...
param(3);
Any help with why this is, or how to get a better fit is greatly appreciated! Thank you!
2 Comments
John D'Errico
on 26 Feb 2014
Edited: John D'Errico
on 26 Feb 2014
In any case, the model fits the data poorly, and it will still do so even if you could get consistent convergence. Do you REALLY believe this model fits the data, or are you just trying to stuff some data into the only model you could think of?
Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!