snnJulia1



In [1]:
stime = 1000
dt = 0.5
d = 8.0
a = 0.02
c = -65.0
b = 0.2
T = round(Int,(ceil(stime/dt)))


Out[1]:
2000

In [2]:
v = zeros(T,1)
u = zeros(T,1)


Out[2]:
2000x1 Array{Float64,2}:
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 ⋮  
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0

In [3]:
v[1] = -70.0
u[1] = -14.0


Out[3]:
-14.0

In [5]:
tic();
for t = 1:T-1
    if (t*dt > 200) && (t*dt < 700)
        Iapp = 7.0;
    else 
        Iapp = 0.0;
    end
    
    if(v[t] < 35.0)
        dv = (v[t]*(0.04*v[t] + 5.0)) + 140.0 - u[t];
        v[t+1] = v[t] + (dv + Iapp)*dt;
        du = a*(b * v[t] - u[t]);
        u[t+1] = u[t] + dt*du;
    else
        v[t] = 35.0;
        v[t+1] = c;
        u[t+1] = u[t] + d;
    end
    
end
toc();


elapsed time: 0.046263686 seconds

In [14]:
using Winston
time = dt*(1:T)
plot(time,v, "r")
title("Izhikevich Neuron")
xlabel("Simulation Time(ms)")
ylabel("Membrane potential (mV)")


Out[14]:

In [ ]: