Non linear curve fitting question

4 Ansichten (letzte 30 Tage)
Chris Porter
Chris Porter am 19 Dez. 2016
Beantwortet: Chris Porter am 20 Dez. 2016
I am trying to fit a model to a set of data. The model is dG/dt=k1*(Gin-G)-k2*G. When you do the integral, you can get, G=Gin*k1/(k1+k2)-A*exp(-t*(k1+k2)), where A, Gin, k1, k2 are constants.
So to test this out, I am using the following code.
%%
Gin=1; k1=.1; k2=.2; dT=.1;
Time=(0:dT:100);
G=zeros(length(Time),1);
%%Generate Test Data
for n=2:length(Time)
dG=k1*(Gin-G(n-1))-k2*G(n-1);
G(n)=G(n-1)+dG*dT;
end
modelfun2=@(b,t)(-b(3)*exp(t*(-b(2)-b(4)))+b(2)*b(1)/(b(2)+b(4)));
beta04=zeros(4,1)+.1;
beta4=lsqcurvefit(modelfun2,beta04,Time',G);
but when I do this I get that beta4=[.3466, .2930, .3333, .0116] when it should be [1, .1 , 5, .2]
Any suggestions on how to help this out? I have tried putting bounds on the parameters, but that hasn't really helped.

Akzeptierte Antwort

Chris Porter
Chris Porter am 20 Dez. 2016
Just realized that I really only have three independent parameters in this equation.
That would explain why I cant get it to converge to the specific solution I want

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by