Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import ipdb # ipdb.set_trace()
- import numpy as np
- import matplotlib.pyplot as plt
- InputCurrent_maxvalue = 8e-9
- C = 1e-9 #capacitance
- Vth = 0.3
- Vreset = 0
- tstep = 1e-3
- Ileak = 0
- times = np.arange(0,5,tstep)
- InputCurrent = 0.5*InputCurrent_maxvalue*(0.5+0.5*np.sin(2*np.pi*times))
- vmembrane = np.zeros(len(times))
- vmembrane[0] = 0
- vout = np.zeros(len(times))
- vout[0] = 0
- for i, t in enumerate(times):
- # I = C_M dV/dt + Il
- # dV/dt = I/C
- dV = InputCurrent[i]/C * tstep
- vmembrane[i] = vmembrane[i-1] + dV
- if vmembrane[i] > Vth:
- vmembrane[i] = 0
- vout[i] = 1
- else:
- vout[i] = 0
- fig, axs = plt.subplots(3)
- fig.suptitle('Integrate and Fire (IF) Spiking Neuron')
- axs[0].plot(times,InputCurrent)
- axs[1].plot(times,vmembrane)
- axs[2].plot(times,vout,'r',label="Voltage (V)" )
- plt.xlabel("Time (s)")
- plt.plot
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement