from
Neurocal
by Zeng Lertmanorat Simulation describing the electrical activity of nerve cell (neuron) by solving cable equation
[Amplitude]=SquarePulse(t)
function [Amplitude]=SquarePulse(t)
%Input
% t (us)
%Output
% Amplitude (uA)
% setting the Amplitude to empty indicates the end of the stimulus
% pulse. This helps speed up the calculation
%----------------------------------------
Pulsewidth = 500; %us
Delay = 0; %us
Amp = -0.1; %uA %for Iinstim
%Amp = -200; %uA %for Iexstim
%----------------------------------------
if t<=Delay
Amplitude=0;
elseif t <= (Delay+Pulsewidth)
Amplitude=Amp;
else
Amplitude=[];
end