%
% a driver and soma pot plotter
%

close all

params

gamma = 2*Ra*(Gm-Gs);

[As,indexes,list,len,lpoint] = convert('final.asc');

As = (4/3)*(1e-8)*As;	% cm

[M,K] = makeMK2(h,list,indexes,len,lpoint);

M = (1e-8)*M;
K = (1e-4)*K;

M(1,1) = M(1,1) + As;
K(1,1) = K(1,1) - As*gamma;

n = size(M,2);

B = 2*Ra*Cm*M;

A = B + dt*K + 2*Ra*Gm*dt*M;
disp('A built')
[L,U] = lu(A);
disp('A factored')

v = zeros(n,1);

for j=1:Nt,

        rhs = B*v;
        t(j) = j*dt;
        rhs(1) = rhs(1) + Ra*dt*stim(t(j))/pi;
        v = U \ (L \rhs);
        v0(j) = v(1);
        fprintf(1,'%d',j);

end

figure(2)
plot(t,v0)
