function cableFN()
% Sample matlab program simulating
% a piece of an axon via neuronal cable equation
% with FitzHugh-Nagumo model of a single membrane compartment.
ff=figure;
N=1024; % Number of spatial compartments (spatial resolution)
% Parameters:
V=ones(1,N)*(-1); 
W=ones(1,N)*(-0.5); 
I=zeros(1,N);
tau = 0.1; tspan = 0:tau:1000;
% Second order derivative operator (sparse matrix)
S=sparse([1:N 1:N 2:N 1],[1:N 2:N 1 1:N ],[-2*ones(1,N) ones(1,2*N) ]);
i=1;
for t=tspan
    if (t>0) I(1,N/4+N/2)=30; end; % to ignite any interesting action 
    if (t>500) I(1,-N/8+N/2)=30; end;
    V = V + tau*((S*V')'-V.^3./3+V-W+I);
    W = W + tau*0.08*(V+0.7-0.8*W);
    if (mod(i,25)==0)
       cla;
       hold on;
       plot(1:N,V+1,'b','Linewidth',2);
       plot(1:N,W/3-2,'g','Linewidth',2);
       plot(1:N,I/40-2.5,'r','Linewidth',2);
       hold off; 
       axis([1 N -3 4]);
       legend('V','n','I');
       drawnow;
       % Uncomment to print frames of the animation:
       % print(ff, '-r150', '-dpng', ['cableFN', num2str(i),'.png']);
    end;
    i=i+1;
    %disp(t);
end;


