-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle_neuron_integrator.2.cpp
More file actions
53 lines (41 loc) · 982 Bytes
/
single_neuron_integrator.2.cpp
File metadata and controls
53 lines (41 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <cmath>
using namespace std;
double threshhold = 22.;
double r = 20;
double u_rest = 10.;
double u_reset = -20;
double tau = 0.4;
double dt = 1e-4;
double length = 20.;
double u1_buffer;
double u2_buffer;
double current(double t,double u){
if (u>threshhold){
return (tau*(u_reset-u))/(dt*r);
} else if (t>1. & t< 10.){
return 1;
} else {
return 0.;
}
}
double leak_potential_change(double u) {
return (1./tau)*(u_rest-u);
}
double activation_potential_change(double t,double u){
return (1./tau)*r*(current(t,u));
}
int main(){
double u = u_rest;
double t;
cout << "time u(t) u_reset u_rest current" << endl;
for(t=0;t<length;t+=dt){
u += dt*(leak_potential_change(u)+activation_potential_change(t,u));
cout << t << " ";
cout << u << " ";
cout << u_reset << " ";
cout << u_rest << " ";
cout << endl;
}
return 0;
}