简体   繁体   中英

system of differential equations with ode45 in matlab

I have got this model for glucose and insulin, and system of differential equations:

微分方程组

Where:

G(t) - the plasma glucose concentration at time t
I(t) - the plasma insulin concentration at time t
X(t) - the interstitial insulin at time t
Gb - the basal plasma glucose concentration
Ib - the basal plasma insulin concentration

which describe the model. I must do an algorithm to estimate parameters with use ode45 in matlab.

Test data is as follows:

测试数据截图

I am not sure how write function for ode45, my idea is as follows:

function [] = cwiczenie3_1a(dane)
a=size(dane);
u=[];
y=[];
for i=1:a(1,1)
  g(i,1)=dane(i,2);
  j(i,1)=dane(i,3);
end
[x t]=ode45(@funkcjajeden,[0 100],[0,0]) 
end

function [dg] = funkcjajeden(t,g)
gb=350;
d=0.1;
ib=120;
k1=1;
k2=2;
k3=1;
dg=zeros(size(g));
dg(1)=(k1*(gb-g(1)))-d*g(1);
dg(2)=(k2*(g(2)-ib))-k3*d;
end

Taking a look to the documentation for ode45 to solve the system of differential equations you should write the function in a file, odefcn.m in this case:

function dg = odefcn(g,k1,k2,k3,gb,ib,d)

  dg = zeros(size(g));
  dg(1) = k1*(gb-g(1)) - d*g(1);
  dg(2) = k2*(g(2)-ib) - k3*d;

And then in another file you solve it by doing:

gb = 350;
d = 0.1;
ib = 120;
k1 = 1;
k2 = 2;
k3 = 1;

tspan = [0 100];
g0 = [0 0];
[t,g] = ode45(@(t,g) odefcn(g,k1,k2,k3,gb,ib,d), tspan, g0);

plot(t,g(:,1),t,g(:,2))

This way you obtain the values for both G(t) an I(t) for that initial values and parameters:

Image

Then, you can compare to the test data and find the value of the parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM