-
Notifications
You must be signed in to change notification settings - Fork 1
/
netsfm_cont.m
executable file
·81 lines (65 loc) · 1.66 KB
/
netsfm_cont.m
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function ns = netsfm_cont(ns, len)
%
% ns = netsfm_cont(ns, len)
%
% Runs or continues simulation by a specified amount of time.
%
% input: ns struct with network & simulation information
% len length of continuation
%
% output: ns, struct with network & updated simulation information
%
% marmaduke 12/05/2012
n_steps = floor(len/ns.dt);
n_output = floor(n_steps/ns.ds);
ts = zeros(1, n_output);
ys = zeros(size(ns.ys, 1), n_output);
rs = zeros(size(ns.rs, 1), n_output);
Is = zeros(size(ns.I), n_output);
ii_out = 1;
t = ns.t;
dt = ns.dt;
ds = ns.ds;
theta = ns.theta;
omega = ns.omega;
rmega = ns.rmega;
G = ns.G;
I = ns.I;
tw = ns.tw;
k = ns.k;
n = ns.n;
r_on = ns.integrate_reduced;
for ii=1:n_steps
fired = theta > pi;
theta(fired) = theta(fired) - 2*pi;
dtheta = 1 + (G*omega + I).*sin(theta);
domega = -omega + k*fired/dt;
theta = theta + dt*dtheta;
omega = omega + dt*domega/tw;
if r_on % ns.integrate_reduced
sqrt0 = 1 - (G*rmega + I).^2;
sqrt0(sqrt0<0) = 0;
drmega = -rmega + sqrt0;
rmega = rmega + dt*drmega/tw;
end
t = t + dt*1;
theta(theta<-pi) = -pi;
if mod(ii, ds) == 0
ts(ii_out) = t;
ys(:, ii_out) = [theta; omega];
rs(:, ii_out) = rmega;
ii_out = ii_out + 1;
% record input pattern
Is(:, ii_out) = ns.I;
end
end
ns.t = t;
ns.theta = theta;
ns.omega = omega;
ns.ts = [ns.ts ts];
ns.ys = [ns.ys ys];
ns.Is = [ns.Is Is];
if r_on % ns.integrate_reduced
ns.rs = [ns.rs rs];
ns.rmega = rmega;
end