-
Notifications
You must be signed in to change notification settings - Fork 6
/
GenerateKuramotoData.m
50 lines (45 loc) · 1.16 KB
/
GenerateKuramotoData.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
function Y = GenerateKuramotoData(A, tSpan, N, K, randicfn, randwfn)
%
% calls kuramoto.m to return solution of Kuramoto model
%
% INPUTS:
%
% A
% an [n x n] adjacency matrix for the network
%
% tSpan
% a [1 x m] vector of times for which you want the solution of the
% ODE returned
%
% N
% a scalar value for the number of random trials requested
%
% K
% a scalar value for connection strength of the network
%
% randicfn
% a function that takes a scalar n and returns an [n x 1] vector
% of (possibly random) initial conditions, one for each node in the
% network
%
% randwfn
% a function that takes a scalar n and retuns an [n x 1] vector
% of (possibly random) natural frequencies w, one for each node
% in the network
%
% OUTPUTS:
%
% Y
% an [n x m x N] matrix of the solution of the ODE for n nodes,
% m time points, and N random trials
n = size(A,1);
m = length(tSpan);
Y = zeros(n,m,N);
for j = 1:N
start = randicfn(n);
freq = randwfn(n);
Y(:,:,j) = kuramoto(start,A,freq,tSpan,K);
end
% if N == 1, want 2D Y
Y = squeeze(Y);
end