i too faced this kind on situation when i was trying to code HH model.
the probable typos are :
1)in writing functions of alpha , beta of m,n,h.
2)interpretaion of parameter's units.
Any way i am giving my code u go thru it. Mail me if you find
difficulties.
% author Gangadhar.G , Computational Neuroscience Laboratory
% Indian Institute of Technology - Madras.
% email : ganges.g at gmail.com or ganges_g at yahoo.co.in
% date : 20 Nov 2005
clc;clear;
Iext = 0.1; % external current
cm = 0.01; % membrane capacitance
dt = 0.05; % time step
ENa = 55.17;
EK = -72.14;
El =-49.42;
gNamax = 1.2; %max conductances
gKmax = 0.36;
glmax = 0.003;
niter = 6000; % max number of iterations
% Intial conditions
vm(1) = -60; % intial membrane voltage
V(1) = vm;
% calculating alphas abd betas for the intial membrane voltage
alpn = 0.01*(vm+50)/(1-exp(-(vm+50)/10));
alpm = 0.1*(vm+35)/(1-exp(-(vm+35)/10));
alph = 0.07*exp(-0.05*(vm+60));
betn = 0.125*exp(-(vm+60)/80);
betm = 4*exp(-0.0556*(vm+60));
beth = 1/(1+exp(-0.1*(vm+30)));
% intial m,n & h
n = alpn/(alpn+betn);
m = alpm/(alpm+betm);
h = alph/(alph+beth);
% the loop for calculation of membrane voltage dynamics is here.
for i = 1:niter,
dm = dt*(alpm*(1-m)-betm*m);
dn = dt*(alpn*(1-n)-betn*n);
dh = dt*(alph*(1-h)-beth*h);
m = m + dm;
n = n + dn;
h = h + dh;
gNa = gNamax*m^3*h;
gK = gKmax*n^4;
gl = glmax;
INa = gNa*(vm-ENa);
IK = gK*(vm-EK);
Il = gl*(vm-El);
dvm = (dt/cm)*(Iext-( INa + IK + Il));
vm = vm + dvm;
V(i+1) = vm;
alpn = 0.01*(vm+50)/(1-exp(-(vm+50)/10));
alpm = 0.1*(vm+35)/(1-exp(-(vm+35)/10));
alph = 0.07*exp(-0.05*(vm+60));
betn = 0.125*exp(-(vm+60)/80);
betm = 4*exp(-0.0556*(vm+60));
beth = 1/(1+exp(-0.1*(vm+30)));
end
tim = dt*(1:niter+1);
plot(tim,V);
xlabel('time in ms');
ylabel('v_m mv');
---------------------------------
regards
Ganges.