%FHN_chain.m
%%SITABHRA SINHA
%%COURSE: Systems Biology, Jan-May 2020
%1-dimensional array of diffusively coupled FHN elements
itrns=5e4; %duration of simulation
N=100; %size of linear array
%Integration parameters
dt=0.01;dx=0.5;
%Parameters
A=3;alpha=0.25;silon=0.02;k=1;
%Coupling
D=0.1;

%Boundary conditions
%e=[N 1:N-1];w=[2:N 1]; %Periodic
e=[1 1:N-1];w=[2:N N]; %No-flux

%Initial conditions
V=zeros(N,1);
%Stimulate the central point
%V(ceil(N/2))=1;
%Stimulate the left end
V(1)=1;
g=zeros(N,1);

for i=1:itrns,
dV=A*V.*(V-alpha).*(1-V)-g+D*((V(e)+V(w)-2*V)/(dx*dx));
dg=silon*(k*V-g);
Vrec(:,i)=V;
V=V+dV*dt;
g=g+dg*dt;

end;

figure,imagesc(Vrec)
figure, hold on,for i=1:100, plot(0.2*i+Vrec(:,i*400)),end;