Clear Filters
Clear Filters

fitting ODE parameters by using lsqnonlin

3 views (last 30 days)
Joël on 15 Nov 2013
Answered: Marylen Sun on 19 Nov 2020
Hello, I'm new to Matlab. I would like to fit two parameters used in differential equations by using lsqnonlin. The idea is to find the parameters by minimising the difference between the experimental curve and the generated curve. I tried to minimize the ssq between the two curves but if you look at the graphs it seems that Matlab somehow takes a wrong average of the difference between the two curves.
The code (one function and one script)looks like this:
global rate;
load('rate'); % experimental data
k0=[0.04,0.02]; %kin4 is the function that generates the
subplot(3,1,1), plot(rate);
subplot(3,1,2), plot(b);
subplot(3,1,3), plot(a);
function [r,y] = kin4( k)
global rate; %Experimental data
[t,y] = ode23s(@kin2,[300/n:300/n:300],[0.1,0.0]);
r=times((rate-y),(rate-y)); %minimizing the ssq
function dy=kin2(t,y)
dy = zeros(2,1);
dy(1) = -k(1)*y(1);
dy(2) = k(1)*y(1)-k(2)*y(2);

Answers (1)

Marylen Sun
Marylen Sun on 19 Nov 2020
Hello, did you find a solution to your problem? I have an equation differential harder but i have to do something like you and he solutions seem not correct, like as you said, the sum squared of the difference is still big and it stopped while the difference is still big. Can you tell me what was your problem please?

Community Treasure Hunt

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

Start Hunting!