Non linear curve fitting question

7 次查看(过去 30 天)
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.

采纳的回答

Chris Porter
Chris Porter 2016-12-20
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

更多回答(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