Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
lsqcurvefit with ODE45

Subject: lsqcurvefit with ODE45

From: Edward

Date: 19 Mar, 2011 18:20:23

Message: 1 of 1

I am trying to curve fit of an ODE using lsqcurvefit.
These are the points that I am trying to fit:
t=[0 2 4 8 12 24];
A=[8.216 8.216 8.002 7.834 7.882 8.312];

My equation is:
alpha=1+B.*(1-exp(-C.*t.*tau));
dydt = Kg.*(1-y./ymax).*y-((C.^H).*Kk)./(C.^H+alpha.*C50k.^H).*y;

I am trying to estimate 6 parameters which are B, tau, ymax, H, C50k, and Kk with minimal sum of squares.
I have start a file, but I am receiving errors such as:
lsqcurvefit stopped because the size of the current step is less than
the default value of the step size tolerance.

my codes are:
%First File
function dydt = BP1(t,y,ModelParams)
C=4;
Kg=2.31;
Kk=ModelParams(1);
C50k=ModelParams(2);
H=ModelParams(3);
ymax=ModelParams(4);
B=ModelParams(5);
tau=ModelParams(6);
alpha=1+B*(1-exp(-C*t*tau));
dydt = Kg*(1-y/((ymax*10^9))*y-((C^H)*Kk)/(C^H+alpha*C50k^H))*y;

%Second File
function y = BP2(ModelParams,t,y0)
[t,y]=ode45(@BP1,t,y0,[],ModelParams);

%Third File
t=[0 2 4 8 12 24];
y0=8.216*10^8;
A=[8.216 8.216 8.002 7.834 7.882 8.312];
ydata=A'*10^8;
ydata(1)=y0;
ModelParams0=[3.2,2,2.4,10,6,.01];
options = optimset('MaxFunEvals', 1000, 'MaxIter', 1000);
ModelParams_Fit=lsqcurvefit(@BP2,ModelParams0,t,ydata,[],[],options,y0);
parameters = (ModelParams_Fit)

Would fmincon be more reliable for parameter estimation?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us