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 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