clear all

% Plot product concentration for hypothetical substrate to product
% reaction S->P with P_init=0M and S_init=1M. 
%
% Executes properly on MATLAB version 9.4.0.813654 (R2018a).
% Executes mostly properly on OCTAVE version 4.2.1.
% Joshua C. Vaughan 4/16/2020

n = 2^8;                            % Number of samples along time axis.
k1 = 1.5e2;                         % Zeroth order rate cosntant. Units are micromolar/second.
k2 = k1/1000;                       % First order rate constant in micromolar/second. For mimicking nonlinear behavior at long times.

t_pts = [0 0.2 0.4 0.66 0.78 0.92];	% Time points. Units are seconds.
t = linspace(0,20,n);           % Time vector. Units are seconds.

P_init = 0;                     % Initial product concentration. Units are micromolar.
S_init = 1000;                  % Initial substrate concentration. Units are micromolar.

P_pts = P_init + k1*t_pts;      % Assuming linear, zeroth-order behavior
P_line = k1*t;                  % Extrapolated line for zeroth-order behavior
P = P_init + S_init*(1-exp(-k2*t));     % Shows nonlinear behavior at long time


% create plot

ax_lw = 2;
pl_lw = 2;
ax_fs = 24;
la_fs = 24;
markersize = 24;
fontname = 'Arial';

figure(1); clf
plot(t,P,'k','linewidth',pl_lw); hold on
plot(t,P_line,'r--','linewidth',pl_lw)
plot(t_pts,P_pts,'r.','markersize',markersize); hold off
xlabel('time (s)','fontsize',la_fs)
ylabel(['[P({\itt})] (' char(181) 'M)'],'fontsize',la_fs)
set(gcf,'color',[1 1 1])
set(gca,'linewidth',ax_lw)
set(gca,'fontsize',ax_fs)
set(gca,'tickdir','out')
set(gca,'fontname',fontname)
ylim([0 1000])
xlim([0 15])
set(gca,'LooseInset',get(gca,'TightInset'));
