%Minimal model for insulin-glucose after Bergman-Cobelli
%   kja 070612

aminit;

data=[0 92 11;2 350 26;4 287 130;6 251 85;8 240 51;10 216 49;
    12 211 45; 14 205 41;16 196 35; 19 192 30;22 172 30; 27 163 27;
    32 142 30; 42 124 22; 52 105 15; 62 92 15; 72 84 11; 82 77 10;
    92 82 8;102 81 11; 122 82 7;142 82 8;162 85 8;182 90 7];
datai=[];
for tt=0:0.1:180;
   datai=[datai;tt,ig_iconc(tt,data)];
end
ts=182;tspan=[0,ts];
x0=[300;0];
[t,x]=ode45('igmodel',tspan,x0);

subplot(321)
pl=plot(t,x(:,1),'b',data(:,1),data(:,2),'bo');
set(pl,'Linewidth', AM_data_linewidth);
amaxis([0 150 0 400]);
ylabel('Glucose [mg/dl]');
daspect(daspect * diag([1 1.8 1]));

subplot(323);
pl=plot(data(:,1),data(:,3),'bo',datai(:,1),datai(:,2),'b-');
%pl=semilogx(data(:,1),data(:,3),'bo',datai(:,1),datai(:,2),'b-');
set(pl,'Linewidth', AM_data_linewidth);
amaxis([0 150 0 140]);
xlabel('Time {\itt} [min]');
ylabel('Insulin [\muU/ml]');
daspect(daspect * diag([1 1.8 1]));

amprint('igresponse.eps');
