26.07.2013 Views

Matematisk Model for Mavesækkens Tømning - Danmarks Tekniske ...

Matematisk Model for Mavesækkens Tømning - Danmarks Tekniske ...

Matematisk Model for Mavesækkens Tømning - Danmarks Tekniske ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

41 % Modified 23.07.09 SW<br />

107<br />

42 % ========================================================================<br />

43 xdot = Hovorka<strong>Model</strong>2pancreas(0,x,u,ug,d,par);<br />

Listing D.5: Hovorka<strong>Model</strong>Simulation2Pancreas.m<br />

1 function [Tx,G,I,X]=Hovorka<strong>Model</strong>Simulation2Pancreas(T,x0,U,ugvec,D,par)<br />

2 % HOVORKAMODELSIMULATION Simulation using the Hovorka model<br />

3 %<br />

4 % Syntax: [Tx,G,I,X]=Hovorka<strong>Model</strong>Simulation2Pancreas(T,x0,U,ugvec,D,par)<br />

5<br />

6 nx = length(x0);<br />

7 N = length(T);<br />

8 Tx(1) = T(1);<br />

9 X = x0';<br />

10 <strong>for</strong> k=1:N−1<br />

11 x = X(end,:)';<br />

12 [Tk,Xk]=ode45(@Hovorka<strong>Model</strong>2pancreas,[T(k) T(k+1)],x,[],U(:,k),...<br />

13 ugvec(:,k),D(:,k),par);<br />

14 X = [X; Xk];<br />

15 Tx = [Tx; Tk];<br />

16 end<br />

17<br />

18 G = X(:,3)/par.VG;<br />

19 I = X(:,5);<br />

Listing D.6: experiment simulation pan con 5.m<br />

1 clear all; close all;<br />

2<br />

3 % Parameters <strong>for</strong> the Steady State.<br />

4 BodyWeight = 70.0;<br />

5 par = HovorkaParametersPancreas(BodyWeight);<br />

6 uss = 0.0; % Basal rate of insulin.<br />

7 dss = 0.0; % Basal rate of glucose.<br />

8<br />

9 % Compute Steady State.<br />

10 Ipo0 = par.Sb;<br />

11 xinit = [0 0 55.9483 23.3399 5.7677 0.0295 0.0047 0.2997 Ipo0 0]';<br />

12 [Gss,Iss,xss]=HovorkaBasalState2Pancreas(uss,0,dss,par,xinit);<br />

13 gss = Gss*par.MwG/10;<br />

14<br />

15 Ts = 10; % Time to eat the glucose [min].<br />

16 dmeal = 40/Ts; % Amount of oral glucose [g/min].<br />

17<br />

18 T = 0:1:5*60; % Time of simulation [min].<br />

19 N = length(T);<br />

20<br />

21 D = repmat(dss,1,N);<br />

22 idd = round([60 61 62 63 64 65 66 67 68 69] + 1); % Time <strong>for</strong> meal [min].<br />

23 D(1,idd) = D(1,idd)+dmeal; % Meal vector.<br />

24<br />

25 BS = 5; % Target value of blood glucose [mmol/L].

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!