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.

244<br />

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

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

246 predCF(1) = 1;<br />

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

248 predCF(k) = predYF(k−1)*15+predCF(k−1);<br />

249 end<br />

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

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

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

253 hold on<br />

254 plot(Time,predCF,'r','linewidth',2)<br />

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

256 legend('Data','dQ/dt = bQ')<br />

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

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

259 print('−depsc', '−tiff', ['modelF'])<br />

260 print('−dpng', '−loose', ['modelF'])<br />

261<br />

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

263 diffF = Cdata − predCF';<br />

264 SSEF = diffF'*diffF;<br />

265 KF = length(DF);<br />

266 AICF = n*log(SSEF/n)+2*KF;<br />

267<br />

268 % <strong>Model</strong> G<br />

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

270 XG = [ones(16,1)];<br />

271 DG = pinv(XG)*Y;<br />

272<br />

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

274 predYG = XG*DG;<br />

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

276 h = figure;<br />

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

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

279 hold on<br />

280 plot(Time(2:end),predYG,'r','linewidth',2)<br />

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

282 axis tight<br />

283<br />

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

285 predCG(1) = 1;<br />

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

287 predCG(k) = predYG(k−1)*15+predCG(k−1);<br />

288 end<br />

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

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

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

292 hold on<br />

293 plot(Time,predCG,'r','linewidth',2)<br />

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

295 legend('Data','dQ/dt = c')<br />

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

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

298 print('−depsc', '−tiff', ['modelG'])

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

Saved successfully!

Ooh no, something went wrong!