lsqcurvefit to fit data- changes with number of data points?

1 view (last 30 days)
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
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?
Brittany
Brittany on 27 Feb 2014
Hi John. Yes, you are right, the fit is not perfect in either graph. That is in fact the reason I started looking at removing the first few data points as they are not related to the time frame I am trying to fit in my x-axis. This is one of ten models I am using in fact, so no, definitely not the first one I could think of. One of the reasons I am obtaining the residuals is so that I can choose the model with the best fit. I believe it to be very important to understand my data and the processes behind the values though, not just accept a theory that mathematically fits my data, but doesn't theoretically make sense.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!