-
Notifications
You must be signed in to change notification settings - Fork 0
/
ode.m
40 lines (35 loc) · 846 Bytes
/
ode.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
function [t, X1, X2] = ode(N,Para,NetUni,NetRnd,x0,StopCond)
RunTime = StopCond{2};
M = Para{1};
x0_uni = x0{1};
x0_rnd = x0{2};
X0_uni = zeros(M,N);
for i=1:N
X0_uni(x0_uni(i),i) = 1;
end;
X0_rnd = zeros(M,N);
for i=1:N
X0_rnd(x0_rnd(i),i) = 1;
end;
tic;
[t1,X1] = GEMF_ODE(Para,NetUni,X0_uni,RunTime);
toc;
tic;
[t2,X2] = GEMF_ODE(Para,NetRnd,X0_rnd,RunTime);
toc;
X1_ = zeros(6,length(t1));
X2_ = zeros(6,length(t2));
for ab = 1:M
X1_(ab,:) = sum(X1(:,ab:M:end),2);
X2_(ab,:) = sum(X2(:,ab:M:end),2);
end
ts1 = timeseries(X1_,t1);
ts2 = timeseries(X2_,t2);
dt = 0.05;
% makes vectors of the same length
[X11,X22] = synchronize(ts1,ts2,'Uniform','Interval', dt);
X1 = X11.data;
X2 = X22.data;
X1 = reshape(X1,6,StopCond{2}/dt+1);
X2 = reshape(X2,6,StopCond{2}/dt+1);
t = X22.time;