필터 지우기
필터 지우기

fitting ODE parameters by using lsqnonlin

조회 수: 3 (최근 30일)
Joël
Joël 2013년 11월 15일
답변: Marylen Sun 2020년 11월 19일
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