fitting ODE parameters by using lsqnonlin

2 次查看(过去 30 天)
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:
clear;clc;
global rate;
load('rate'); % experimental data
k0=[0.04,0.02]; %kin4 is the function that generates the
[x]=lsqnonlin(@kin4,k0);
[a,b]=kin4(x);
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
n=size(rate,1);
[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);
end
end

回答(1 个)

Marylen Sun
Marylen Sun 2020-11-19
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?

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by