close all clear all clc load('convolution_in_matlab_insuline_data.mat') % defines T, x, tx tg = 0:T:420; % we use the same range of x g1 = .76*exp(-.14*tg)+.24*exp(-0.2*tg); y1 = T*conv(x,g1); ty = tx(1)+tg(1):T:tx(end)+tg(end); g2 = .76*exp(-.14*tg)+.24*exp(-0.02*tg); y2 = T*conv(x,g2); g3 = .76*exp(-.14*tg)+.24*exp(-0.002*tg); y3 = T*conv(x,g3); figure subplot(2,2,1) plot(tx,x) grid axis([0 420 ylim]) xlabel('t [min]') ylabel('x(t) [pmol/L/min]') title('pancreatic secretion') subplot(2,2,2) plot(tg,g1,tg,g2,tg,g3) grid axis([0 420 ylim]) xlabel('t') ylabel('g(t)') legend('b=0.2','b=0.02','b=0.002') title('filter response') subplot(2,1,2) plot(ty,y1,ty,y2,ty,y3) grid axis([0 420 ylim]) xlabel('t') ylabel('y(t) [pmol/L]') title('plasma concentration') sgtitle('hormone C-peptide kinetics') % printing figure in png format set(gcf,'PaperUnits','inches','PaperPosition',[0 0 6 4.5]) print -dpng homework2.png -r100