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

96 MATLAB kode til behandling af forsøgsdata 134 plot(Time,Cdata,'.b','MarkerSize',15) 135 hold on 136 plot(Time,predCC,'r','linewidth',2) 137 xlabel('Time [min]','fontsize',14); ylabel('Q','fontsize',14); 138 legend('Data','dQ/dt = aQˆ2 + c') 139 axis([0 Time(end) 0 1]) 140 set(get(h,'CurrentAxes'),'fontsize',14) 141 print('−depsc', '−tiff', ['modelC']) 142 print('−dpng', '−loose', ['modelC']) 143 144 % Calculating Sum of Square Errors and AIC 145 diffC = Cdata − predCC'; 146 SSEC = diffC'*diffC; 147 KC = length(DC); 148 AICC = n*log(SSEC/n)+2*KC; 149 150 % Model D 151 % Defining matrix X and finding parameters. 152 XD = [Cdata(1:end−1) ones(16,1)]; 153 DD = pinv(XD)*Y; 154 155 % Calculating the model of Y. 156 predYD = XD*DD; 157 % Plot of the model of Y with datapoints. 158 h = figure; 159 subplot(1,2,1) 160 plot(Time(2:end),Y,'b','linewidth',2) 161 hold on 162 plot(Time(2:end),predYD,'r','linewidth',2) 163 xlabel('Time [min]','fontsize',14); ylabel('dQ/dt','fontsize',14); 164 axis tight 165 166 % Calculating the model of data. 167 predCD(1) = 1; 168 for k = 2:17 169 predCD(k) = predYD(k−1)*15+predCD(k−1); 170 end 171 % Plot the model of data with datapoints. 172 subplot(1,2,2) 173 plot(Time,Cdata,'.b','MarkerSize',15) 174 hold on 175 plot(Time,predCD,'r','linewidth',2) 176 xlabel('Time [min]','fontsize',14); ylabel('Q','fontsize',14); 177 legend('Data','dQ/dt = bQ + c') 178 axis([0 Time(end) 0 1]) 179 set(get(h,'CurrentAxes'),'fontsize',14) 180 print('−depsc', '−tiff', ['modelD']) 181 print('−dpng', '−loose', ['modelD']) 182 183 % Calculating Sum of Square Errors and AIC 184 diffD = Cdata − predCD'; 185 SSED = diffD'*diffD; 186 KD = length(DD); 187 AICD = n*log(SSED/n)+2*KD; 188

189 %%%%%%%%%%%%%%%%%%%%%%%%% 1 parameter %%%%%%%%%%%%%%%%%%%%%%%%% 190 % Model E 191 % Defining matrix X and finding parameters. 192 XE = [Cdata(1:end−1).*Cdata(1:end−1)]; 193 DE = pinv(XE)*Y; 194 195 % Calculating the model of Y. 196 predYE = XE*DE; 197 % Plot of the model of Y with datapoints. 198 h = figure; 199 subplot(1,2,1) 200 plot(Time(2:end),Y,'b','linewidth',2) 201 hold on 202 plot(Time(2:end),predYE,'r','linewidth',2) 203 xlabel('Time [min]','fontsize',14); ylabel('dQ/dt','fontsize',14); 204 axis tight 205 206 % Calculating the model of data. 207 predCE(1) = 1; 208 for k = 2:17 209 predCE(k) = predYE(k−1)*15+predCE(k−1); 210 end 211 % Plot the model of data with datapoints. 212 subplot(1,2,2) 213 plot(Time,Cdata,'.b','MarkerSize',15) 214 hold on 215 plot(Time,predCE,'r','linewidth',2) 216 xlabel('Time [min]','fontsize',14); ylabel('Q','fontsize',14); 217 legend('Data','dQ/dt = aQˆ2') 218 axis([0 Time(end) 0 1]) 219 set(get(h,'CurrentAxes'),'fontsize',14) 220 print('−depsc', '−tiff', ['modelE']) 221 print('−dpng', '−loose', ['modelE']) 222 223 % Calculating Sum of Square Errors and AIC 224 diffE = Cdata − predCE'; 225 SSEE = diffE'*diffE; 226 KE = length(DE); 227 AICE = n*log(SSEE/n)+2*KE; 228 229 % Model F 230 % Defining matrix X and finding parameters. 231 XF = [Cdata(1:end−1)]; 232 DF = pinv(XF)*Y; 233 234 % Calculating the model of Y. 235 predYF = XF*DF; 236 % Plot of the model of Y with datapoints. 237 h = figure; 238 subplot(1,2,1) 239 plot(Time(2:end),Y,'b','linewidth',2) 240 hold on 241 plot(Time(2:end),predYF,'r','linewidth',2) 242 xlabel('Time [min]','fontsize',14); ylabel('dQ/dt','fontsize',14); 243 axis tight 97

96 MATLAB kode til behandling af <strong>for</strong>søgsdata<br />

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

135 hold on<br />

136 plot(Time,predCC,'r','linewidth',2)<br />

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

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

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

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

141 print('−depsc', '−tiff', ['modelC'])<br />

142 print('−dpng', '−loose', ['modelC'])<br />

143<br />

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

145 diffC = Cdata − predCC';<br />

146 SSEC = diffC'*diffC;<br />

147 KC = length(DC);<br />

148 AICC = n*log(SSEC/n)+2*KC;<br />

149<br />

150 % <strong>Model</strong> D<br />

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

152 XD = [Cdata(1:end−1) ones(16,1)];<br />

153 DD = pinv(XD)*Y;<br />

154<br />

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

156 predYD = XD*DD;<br />

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

158 h = figure;<br />

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

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

161 hold on<br />

162 plot(Time(2:end),predYD,'r','linewidth',2)<br />

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

164 axis tight<br />

165<br />

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

167 predCD(1) = 1;<br />

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

169 predCD(k) = predYD(k−1)*15+predCD(k−1);<br />

170 end<br />

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

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

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

174 hold on<br />

175 plot(Time,predCD,'r','linewidth',2)<br />

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

177 legend('Data','dQ/dt = bQ + c')<br />

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

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

180 print('−depsc', '−tiff', ['modelD'])<br />

181 print('−dpng', '−loose', ['modelD'])<br />

182<br />

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

184 diffD = Cdata − predCD';<br />

185 SSED = diffD'*diffD;<br />

186 KD = length(DD);<br />

187 AICD = n*log(SSED/n)+2*KD;<br />

188

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

Saved successfully!

Ooh no, something went wrong!