%ksim runs a dynamic simulation using Systems Biology Toolbox 2 and plots 
clear;
model = SBmodel('model7.txt');  %initialize model

%parameters
alpha_m = 1;
alpha_s = 40;    %at induced
alpha_r = 200;    %at induced

%%Simulation
time = 6;  %running time. Glucose event at t = 6
[out] = SBsimulate(model,time);

%%PLot
t = out.time;
m = out.statevalues(:,1);   %m
s = out.statevalues(:,2);
r = out.statevalues(:,3);

%scale to max steady_state at induced levels

s = s .* (alpha_m/alpha_s);
r = r .* (alpha_m/alpha_r);

%ss_r = alpha_r/beta_r;
%r = r ./ss_r;
%Binary on off of s and r
%s = gt(t, 1);   %Check model for event time   
%r = gt(t, 3);

width = 4;  %Line width


subplot(3,1,1)
h1 = plot(t,m); %handle
set(h1, 'color', [51/255, 102/255, 204/255], 'LineWidth',width)
set(gca, 'XTickLabel',[])

subplot(3,1,2)
h2 = plot(t,s);
set(h2, 'color', [237/255, 28/255, 36/255],'LineWidth',width)
set(gca, 'XTickLabel',[])

subplot(3,1,3)
h3 = plot(t,r,'g-');
set(h3, 'color', [102/255, 204/255, 0],  'LineWidth',width)