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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

108 MATLAB kode til simulering af <strong>for</strong>søgsscenarie<br />

26 Tx = [];<br />

27 G = [];<br />

28 I = [];<br />

29 X = [];<br />

30 IV ins = repmat(12,1,N); % Constant rate of insulin infusion [mU/min].<br />

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

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

33<br />

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

35 <strong>for</strong> t = 0:5:N−2<br />

36 if t == 0<br />

37 Xx = xss;<br />

38 end<br />

39 IV glu(t+1:t+5) = IV glu(t+1:t+5)+iv glu bolus;<br />

40 [tx,Gx,Ix,Xx] = Hovorka<strong>Model</strong>Simulation2Pancreas...<br />

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);<br />

42 Xx = Xx(end,:)';<br />

43 if Gx > BS<br />

44 iv glu bolus = iv glu bolus − 0.25;<br />

45 elseif Gx < BS<br />

46 iv glu bolus = iv glu bolus + 0.25;<br />

47 end<br />

48 if iv glu bolus < 0<br />

49 iv glu bolus = 0;<br />

50 end<br />

51 Tx = [Tx; tx(1)];<br />

52 G = [G; Gx(1)];<br />

53 I = [I; Ix(1)];<br />

54 X = [X; Xx(1)];<br />

55 end<br />

56<br />

57 % Plot of glucose concentration in plasma.<br />

58 h = figure(1);<br />

59 subplot(221)<br />

60 plot([Tx(1) Tx(end)],[5 5],'r−',Tx,G,'b−','linewidth',2); grid;<br />

61 xlabel('time [min]','fontsize',14); ylabel('G (mmol/L)','fontsize',14);<br />

62 ylim([0 10]); xlim([Tx(1) Tx(end)]);<br />

63 text(60,6,'\downarrow','fontsize',14)<br />

64 hold on;<br />

65 fill([Tx(1) Tx(end) Tx(end) Tx(1)],...<br />

66 [70/par.MwG*10 70/par.MwG*10 140/par.MwG*10 140/par.MwG*10],...<br />

67 'g','facealpha',0.2)<br />

68 hold off<br />

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

70 legend('Target value of BS','Actual value of BS','Location','NorthEast')<br />

71<br />

72 % Plot of insulin concentration in plasma.<br />

73 subplot(222)<br />

74 plot(Tx,I,'b−','linewidth',2);<br />

75 grid; xlabel('time [min]','fontsize',14); ylabel('I (mU/L)','fontsize',14);<br />

76 xlim([Tx(1) Tx(end)])<br />

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

78<br />

79 % Plot of oral glucose load and iv glucose infusion.<br />

80 T=T/60;

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

Saved successfully!

Ooh no, something went wrong!