% gwave.m
% Principles of Computational Modelling in Neuroscience
% Sterratt, Graham, Gillies, Willshaw
% Cambridge University Press, June 2011
% Figure 7.2: Simple synaptic conductance waveforms
% B. Graham, Computing Science & Maths, University of Stirling
% Contact: b.graham@cs.stir.ac.uk
% Last update: 1-7-2011

tmax=8;
dt=0.01;
t=0:dt:tmax;
tau=1;
tau2=3;
ts=1;
tr=t(round(ts/dt):length(t))-(ts-dt);


% Single exponential
gse=zeros(size(t));
gse(round(ts/dt):length(t))=exp(-tr/tau2);

% Alpha
gal=zeros(size(t));
galp=tau/exp(1);
gal(round(ts/dt):length(t))=tr.*exp(-tr/tau)/galp;

% Dual exponential
gde=zeros(size(t));
tp=(tau*tau2)*log(tau2/tau)/(tau2-tau);
gdep=(tau*tau2)*(exp(-tp/tau2)-exp(-tp/tau))/(tau2-tau);
gde(round(ts/dt):length(t))=(tau*tau2)*(exp(-tr/tau2)-exp(-tr/tau))/((tau2-tau)*gdep);

tsize=9;
lsize=9;
nsize=9;

subplot(1,3,1);
plot(t,gse,'k-');
title('(a) Single exponential','FontSize',tsize,'FontName','Helvetica');
xlabel('t (msecs)','FontSize',lsize,'FontName','Helvetica');
ylabel('Conductance','FontSize',lsize,'FontName','Helvetica');
axis([0 tmax 0 1.02]);
set(gca,'Box','off');

subplot(1,3,2);
plot(t,gal,'k-');
title('(b) Alpha function','FontSize',tsize,'FontName','Helvetica');
xlabel('t (msecs)','FontSize',lsize,'FontName','Helvetica');
axis([0 tmax 0 1.02]);
set(gca,'Box','off');

subplot(1,3,3);
plot(t,gde,'k-');
title('(c) Dual exponential','FontSize',tsize,'FontName','Helvetica');
xlabel('t (msecs)','FontSize',lsize,'FontName','Helvetica');
axis([0 tmax 0 1.02]);
set(gca,'Box','off');

set(findobj('Type','line'),'LineWidth',0.8);
set(findobj('Type','text'),'FontSize',nsize,'FontName','Helvetica');
