clear all;

%%------------------------------------------------------------------
%This is a Matlab script that generates Fig. 1B
%The script can be executed by using "script1B" in the command window
%The script calculates reaction rates using Eq. 1 in the main text
%    dc/dt = alpha + c/(kappa + c) - (1 + phi/(delta + gamma*c))*c
%%---------------------------------------

%define the range of c
c=linspace(0,1,100);

%define parameters
alpha=1e-3;
kappa=0.5;
phi=5e-6;
delta=1e-4;
gamma=1e-4;

%solve for the first two terms of Eq. 1
y1=alpha+c./(kappa+c);

%solve for the last term of Eq. 1
y2=(1+phi./(delta+gamma*c)).*c;

%plot results
figure;
line1=plot(c,y1);hold all;
set(line1,'LineWidth',4,'LineStyle','-','Color',[0 0 0]);
line2=plot(c,y2);
set(line2,'LineWidth',4,'LineStyle','.','Color',[0 0 0]);
axis([0 0.5 0 0.5]);
set(gca,'FontSize',30,'FontName','Arial');
ylabel('rate');xlabel('c');
