Non linear curve fitting question

4 visualizaciones (últimos 30 días)
Chris Porter
Chris Porter el 19 de Dic. de 2016
Respondida: Chris Porter el 20 de Dic. de 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.

Respuesta aceptada

Chris Porter
Chris Porter el 20 de Dic. de 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

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by