I have the parametric system of differential equations and real data and I want to estimate the parameters so that minimize the sum square error between real and expected data. The data:
time y(1) y(2) y(3) y(4)1 957 43 0 02 857 110 33 03 557 387 51 54 342 496 150 125 224 465 280 316 123 407 350 1207 79 291 440 1908 35 226 385 3549 29 111 320 54010 17 80 215 68811 2 50 150 79812 0 28 92 88013 0 25 55 92014 0 5 37 95815 0 7 18 97516 0 1 4 99517 0 0 2 99818 0 0 2 99819 0 0 1 99920 0 0 0 1000
I made the system of differential equations
function dy=RModel_1(v,t,y) dy=zeros(4,1); N=y(1)+y(2)+y(3)+y(4); dy(1)=-v(1)*y(1)*y(3)/N-v(2)*y(1); dy(2)=v(1)*y(1)*y(3)/N-v(3)*y(2)-v(4)*y(2)*y(3)/N-v(5)*y(2); dy(3)=v(2)*y(1)+v(3)*y(2)*y(2)+v(4)*y(2)*y(3)/N-v(6)*y(3); dy(4)=v(5)*y(2)+v(6)*y(3); end
and the optimization function of errors
function sse=RModer(v) y0=[477.0 6.0 21.0 6.0]; [T Y]=ode23s(@(t,y) RModel_1(v,t,y),tdata,y0) sse=sum((ydata-ys).^2); end
Finally, I want to call a function such as fminsearch or lsqcurvefit or lsqnonlin to return the estimated parameters.
I understand that my code has mistakes. How can I overcome them?
Thank you
Best Answer