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 ...

26.07.2013 Views

108 MATLAB kode til simulering af forsøgsscenarie 26 Tx = []; 27 G = []; 28 I = []; 29 X = []; 30 IV ins = repmat(12,1,N); % Constant rate of insulin infusion [mU/min]. 31 IV glu = zeros(1,N); 32 iv glu bolus = 0.0; % Glucosebolus at the beginning [g/min]. 33 34 % Control algorithm for iv glucoseadministration. 35 for t = 0:5:N−2 36 if t == 0 37 Xx = xss; 38 end 39 IV glu(t+1:t+5) = IV glu(t+1:t+5)+iv glu bolus; 40 [tx,Gx,Ix,Xx] = HovorkaModelSimulation2Pancreas... 41 (T(t+1):T(t+5),Xx,IV ins(t+1:t+5),IV glu(t+1:t+5),D(t+1:t+5),par); 42 Xx = Xx(end,:)'; 43 if Gx > BS 44 iv glu bolus = iv glu bolus − 0.25; 45 elseif Gx < BS 46 iv glu bolus = iv glu bolus + 0.25; 47 end 48 if iv glu bolus < 0 49 iv glu bolus = 0; 50 end 51 Tx = [Tx; tx(1)]; 52 G = [G; Gx(1)]; 53 I = [I; Ix(1)]; 54 X = [X; Xx(1)]; 55 end 56 57 % Plot of glucose concentration in plasma. 58 h = figure(1); 59 subplot(221) 60 plot([Tx(1) Tx(end)],[5 5],'r−',Tx,G,'b−','linewidth',2); grid; 61 xlabel('time [min]','fontsize',14); ylabel('G (mmol/L)','fontsize',14); 62 ylim([0 10]); xlim([Tx(1) Tx(end)]); 63 text(60,6,'\downarrow','fontsize',14) 64 hold on; 65 fill([Tx(1) Tx(end) Tx(end) Tx(1)],... 66 [70/par.MwG*10 70/par.MwG*10 140/par.MwG*10 140/par.MwG*10],... 67 'g','facealpha',0.2) 68 hold off 69 set(get(h,'CurrentAxes'),'fontsize',14) 70 legend('Target value of BS','Actual value of BS','Location','NorthEast') 71 72 % Plot of insulin concentration in plasma. 73 subplot(222) 74 plot(Tx,I,'b−','linewidth',2); 75 grid; xlabel('time [min]','fontsize',14); ylabel('I (mU/L)','fontsize',14); 76 xlim([Tx(1) Tx(end)]) 77 set(get(h,'CurrentAxes'),'fontsize',14) 78 79 % Plot of oral glucose load and iv glucose infusion. 80 T=T/60;

109 81 subplot(223) 82 stairs(T,D,'b−','linewidth',2) 83 hold on 84 stairs(T,IV glu,'m−','linewidth',2); grid; 85 xlabel('time [hr]','fontsize',14); ylabel('Glucose (g/min)','fontsize',14); 86 xlim([T(1) T(end)]); ylim([0 10]); 87 text(2.5,7,['Total glucose = ' num2str(sum(IV glu)) 'g'],'fontsize',12) 88 set(get(h,'CurrentAxes'),'fontsize',14) 89 legend('Meal','IV glucose') 90 91 % Plot of iv insulin infusion. 92 subplot(224) 93 stairs(T,IV ins,'b−','linewidth',2); grid; 94 xlabel('time [hr]','fontsize',14); 95 ylabel('Insulin infusion (mU/min)','fontsize',14); 96 xlim([T(1) T(end)]); ylim([0 max(IV ins)+1]); 97 set(get(h,'CurrentAxes'),'fontsize',14) 1 clear all; close all; 2 Listing D.7: experiment simulation pan con 10.m 3 % Parameters for the Steady State. 4 BodyWeight = 70.0; 5 par = HovorkaParametersPancreas(BodyWeight); 6 uss = 0.0; % Basal rate of insulin. 7 dss = 0.0; % Basal rate of glucose. 8 9 % Compute Steady State. 10 Ipo0 = par.Sb; 11 xinit = [0 0 55.9483 23.3399 5.7677 0.0295 0.0047 0.2997 Ipo0 0]'; 12 [Gss,Iss,xss]=HovorkaBasalState2Pancreas(uss,0,dss,par,xinit); 13 gss = Gss*par.MwG/10; 14 15 Ts = 10; % Time to eat the glucose [min]. 16 dmeal = 40/Ts; % Amount of oral glucose [g/min] 17 18 T = 0:1:5*60; % Time of simulation [min]. 19 N = length(T); 20 21 D = repmat(dss,1,N); 22 idd = round([60 61 62 63 64 65 66 67 68 69] + 1); % Time for meal [min]. 23 D(1,idd) = D(1,idd)+dmeal; % Meal vector. 24 25 BS = 10; % Target value of blood glucose [mmol/L]. 26 Tx = []; 27 G = []; 28 I = []; 29 X = []; 30 IV ins = repmat(uss,1,N); % None insulin infusion [mU/min]. 31 IV glu = zeros(1,N); 32 iv glu bolus = 5; % Glucosebolus at the beginning [g/min]. 33 34 % Control algorithm for iv glucoseadministration.

109<br />

81 subplot(223)<br />

82 stairs(T,D,'b−','linewidth',2)<br />

83 hold on<br />

84 stairs(T,IV glu,'m−','linewidth',2); grid;<br />

85 xlabel('time [hr]','fontsize',14); ylabel('Glucose (g/min)','fontsize',14);<br />

86 xlim([T(1) T(end)]); ylim([0 10]);<br />

87 text(2.5,7,['Total glucose = ' num2str(sum(IV glu)) 'g'],'fontsize',12)<br />

88 set(get(h,'CurrentAxes'),'fontsize',14)<br />

89 legend('Meal','IV glucose')<br />

90<br />

91 % Plot of iv insulin infusion.<br />

92 subplot(224)<br />

93 stairs(T,IV ins,'b−','linewidth',2); grid;<br />

94 xlabel('time [hr]','fontsize',14);<br />

95 ylabel('Insulin infusion (mU/min)','fontsize',14);<br />

96 xlim([T(1) T(end)]); ylim([0 max(IV ins)+1]);<br />

97 set(get(h,'CurrentAxes'),'fontsize',14)<br />

1 clear all; close all;<br />

2<br />

Listing D.7: experiment simulation pan con 10.m<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 = 10; % Target value of blood glucose [mmol/L].<br />

26 Tx = [];<br />

27 G = [];<br />

28 I = [];<br />

29 X = [];<br />

30 IV ins = repmat(uss,1,N); % None insulin infusion [mU/min].<br />

31 IV glu = zeros(1,N);<br />

32 iv glu bolus = 5; % Glucosebolus at the beginning [g/min].<br />

33<br />

34 % Control algorithm <strong>for</strong> iv glucoseadministration.

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

Saved successfully!

Ooh no, something went wrong!