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

1 次查看(过去 30 天)
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 个评论
John D'Errico
John D'Errico 2014-2-26
编辑:John D'Errico 2014-2-26
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 2014-2-27
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by