Non linear curve fitting question

7 ビュー (過去 30 日間)
Chris Porter
Chris Porter 2016 年 12 月 19 日
回答済み: Chris Porter 2016 年 12 月 20 日
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 Center および File ExchangeGet 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