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.

79 % Plot of the model of Y with datapoints.<br />

80 h = figure;<br />

81 subplot(1,2,1)<br />

82 plot(Time(2:end),Y,'b','linewidth',2)<br />

83 hold on<br />

84 plot(Time(2:end),predYB,'r','linewidth',2)<br />

85 xlabel('Time [min]','fontsize',14); ylabel('dQ/dt','fontsize',14);<br />

86 axis tight<br />

87<br />

88 % Calculating the model of data.<br />

89 predCB(1) = 1;<br />

90 <strong>for</strong> k = 2:17<br />

91 predCB(k) = predYB(k−1)*15+predCB(k−1);<br />

92 end<br />

93 % Plot the model of data with datapoints.<br />

94 subplot(1,2,2)<br />

95 plot(Time,Cdata,'.b','MarkerSize',15)<br />

96 hold on<br />

97 plot(Time,predCB,'r','linewidth',2)<br />

98 xlabel('Time [min]','fontsize',14); ylabel('Q','fontsize',14);<br />

99 legend('Data','dQ/dt = aQˆ2 + bQ')<br />

100 axis([0 Time(end) 0 1])<br />

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

102 print('−depsc', '−tiff', ['modelB'])<br />

103 print('−dpng', '−loose', ['modelB'])<br />

104<br />

105 % Calculating Sum of Square Errors and AIC<br />

106 diffB = Cdata − predCB';<br />

107 SSEB = diffB'*diffB;<br />

108 KB = length(DB);<br />

109 AICB = n*log(SSEB/n)+2*KB;<br />

110<br />

111 % <strong>Model</strong> C<br />

112 % Defining matrix X and finding parameters.<br />

113 XC = [Cdata(1:end−1).*Cdata(1:end−1) ones(16,1)];<br />

114 DC = pinv(XC)*Y;<br />

115<br />

116 % Calculating the model of Y.<br />

117 predYC = XC*DC;<br />

118 % Plot of the model of Y with datapoints.<br />

119 h = figure;<br />

120 subplot(1,2,1)<br />

121 plot(Time(2:end),Y,'b','linewidth',2)<br />

122 hold on<br />

123 plot(Time(2:end),predYC,'r','linewidth',2)<br />

124 xlabel('Time [min]','fontsize',14); ylabel('dQ/dt','fontsize',14);<br />

125 axis tight<br />

126<br />

127 % Calculating the model of data.<br />

128 predCC(1) = 1;<br />

129 <strong>for</strong> k = 2:17<br />

130 predCC(k) = predYC(k−1)*15+predCC(k−1);<br />

131 end<br />

132 % Plot the model of data with datapoints.<br />

133 subplot(1,2,2)<br />

95

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

Saved successfully!

Ooh no, something went wrong!