-
Notifications
You must be signed in to change notification settings - Fork 1
/
StabilityModel.m
59 lines (44 loc) · 1.21 KB
/
StabilityModel.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
% simulate using artificial matrices
%% init
% clear workspace
clearvars();
% paths
addpath(genpath('./Helper Functions/'));
addpath(genpath('./BCT/'));
% load settings
settings = Settings();
% focal or diffuse injury
settings.focal = false;
% set 400000 steps, the same as in case of Stam for stability exploration
settings.steps = 400000;
% distance matrix
Dist = DistMatrix(settings.N);
% number of iterations and the variable to store results
iterations = 10;
iteration = 0;
R = zeros(iterations, 1);
for i = 1:iterations
%% simulate
iteration = iteration + 1;
disp(['Processing: ', num2str(iteration), '/', num2str(iterations)])
% run
[C_t, E_t, L_s] = NMM(settings, Dist, true);
% extract once it is stable
s = (size(C_t, 1)/2)+1;
C_s = C_t(s:end,:,:);
minC = ones(32);
minC(logical(eye(size(minC)))) = 0;
maxC = zeros(32);
maxC(logical(eye(size(maxC)))) = 0;
for k = 1:size(C_s, 1)
C = squeeze(C_s(k,:,:));
minC(C < minC) = C(C < minC);
maxC(C > maxC) = C(C > maxC);
end
% calculate
D = maxC - minC;
maxD = max(max(D));
R(iteration,:) = maxD;
end
% save
csvwrite('./R/Results/stability/Model_extensive.csv', R);