function ret = burster_cable_circle()
ff=figure;
N=80000;
M=2000;

C_d=ones(1,M);
E_L=ones(1,M)*(-80);
g_L=ones(1,M)*8;
g_Na=ones(1,M)*20;
g_K=ones(1,M)*9;
E_Na=ones(1,M)*60;
g_K_s=ones(1,M)*20;
g_Na_s=ones(1,M)*3;

E_K=ones(1,M)*(-90);
E_K_s=ones(1,M)*(-90);
V=ones(1,M)*(-63.5); 
V_rest=ones(1,M)*(-65); 
I=zeros(1,M);
n=n_inf(V);
s=s_inf(V);
s1=s1_inf(V);
I=zeros(1,M);
VV=zeros(N,1);  II=zeros(N,1); nn=zeros(N,1); ss=zeros(N,1);
tau = 600/N; tspan = 0:tau:600;
%S=4*sparse([1:M 1:M 2:M 1],[1:M 2:M 1 1:M ],[-2*ones(1,M) ones(1,2*M) ]);
%loop
S=4*sparse([1:M 1:(M-1) 2:M ],[1:M 2:M  1:(M-1) ],[-1 -2*ones(1,M-2) -1 ones(1,(2*M-2)) ]);
i=1;

for t=tspan
    I(1,:)=0;
    if (t>1)&&(t<1.5) I(1,(M-10):(M))=500; end; % to ignite any interesting action 
    V = V + tau*((randn(1,M)*5 + I + (S*V')'- g_L.*(V-E_L)-g_Na.*m_inf(V).*(V-E_Na)-g_Na_s.*s1.*(V-E_Na)-g_K.*n.*(V-E_K)-g_K_s.*s.*(V-E_K_s))./C_d);
    n = n + tau*(n_inf(V) - n);    
    s = s + tau*(s_inf(V) - s)./50; 
    s1 = s1 + tau*(s1_inf(V) - s1)./20;

    i=i+1;
    if (mod(i,25)==0)
       cla;
       plot(1:M,V,1:M,n*50-100,1:M,s*50-100,1:M,s1*50-100,1:M,I/15-120,'Linewidth',1);
       axis([1 M -120 40]);
       legend('V','n','s_K','s_{Na}','I');
       disp(num2str(t));
       drawnow;
       % Uncomment to print frames of the animation:
       print(ff, '-r200', '-dpng', ['cable_burst', num2str(i),'.png']);
    end;
end;
return;


function ret = m_inf(v)
   ret=1./(1+exp((-20-v)./15));

function ret = n_inf(v)
   ret=1./(1+exp((-25-v)./5));

function ret = s_inf(v)
   ret=1./(1+exp((-20-v)./5));
   
function ret = s1_inf(v)
   ret=1./(1+exp((-40-v)./5));




