%this file finds the nullclines for the rHH equations

Vn =.01+ [-10:115]';

AM=.1*(25.-Vn)./(exp(2.5 -0.1*Vn)-1.);
BM=4.*exp(-Vn/18.);
AN=.01*(10.-Vn)./(exp(1.-0.1*Vn)-1.);
BN=.125*exp(-Vn/80.);

ninf = AN./(AN+BN);

aminf = AM./(AM+BM);
aminf = aminf.^3;

N = length(Vn);
na = zeros(N,1);
n0 = na;
eval_Fvn
Fa = Fvn;

nb = ones(N,1);
n0 = nb;
eval_Fvn
Fb = Fvn;

for j = 1:15
    nc = (na+nb)/2;
    n0 = nc;
    eval_Fvn
    Fc = Fvn;
    for k = 1:N
        if (Fc(k)*Fb(k)>0)
            Fb(k) = Fc(k);
            nb(k) = nc(k);
        else
            Fa(k) = Fc(k);
            na(k) = nc(k);
        end
        
    end
end
