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 = 1e-9
- C = 1e-9 #capacitance
- Vth = 0.3
- Vreset = 0
- tstep = 1e-3
- Ileak = 0
- times = np.arange(0,1,tstep)
- 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/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(2)
- fig.suptitle('Integrate and Fire (IF) Spiking Neuron')
- axs[0].plot(times,vmembrane)
- plt.xlabel("Time (s)")
- axs[1].plot(times,vout,'r')
- plt.xlabel("Time (s)")
- plt.ylabel("Output Voltage (V)")
- plt.plot
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement