-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fig_S4_plot.m
67 lines (50 loc) · 2.6 KB
/
Fig_S4_plot.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
function Fig_S4_plot
%plot Fig_S4, based on the data generated by Fig_S4_generate
%NOTE: first run Fig_S4_generate( seed ) for all seed=1:num_seeds
%the number of seeds
num_seeds = 10;
%the number of different networks per seed
num_networks_per_seed = 10;
%the number of different network sizes
num_N_all = 18;
%pre-allocate the rank of the linear system
rank_vs_N_LV_all = nan( num_networks_per_seed*num_seeds, num_N_all );
rank_vs_N_MP_all = nan( num_networks_per_seed*num_seeds, num_N_all );
rank_vs_N_MM_all = nan( num_networks_per_seed*num_seeds, num_N_all );
rank_vs_N_SIS_all = nan( num_networks_per_seed*num_seeds, num_N_all );
rank_vs_N_kuramoto_all = nan( num_networks_per_seed*num_seeds, num_N_all );
rank_vs_N_cw_all = nan( num_networks_per_seed*num_seeds, num_N_all );
%loop over all seeds
for curr_seed = 1:num_seeds
%the filename to save/read the results
filename = strcat( './results/Fig_S4_seed_', num2str( curr_seed ));
if exist( strcat( filename, '.mat' ), 'file' ) ~= 2
error( 'First run Fig_S4_generate for all seeds 1:num_seeds ')
else
load( strcat( filename, '.mat' ));
%save the results of curr_seed to rank_vs_N_LV_all etc
rank_vs_N_LV_all( ( curr_seed - 1 )*num_networks_per_seed + 1:curr_seed*num_networks_per_seed, : ) = rank_vs_N_LV;
rank_vs_N_MP_all( ( curr_seed - 1 )*num_networks_per_seed + 1:curr_seed*num_networks_per_seed, : ) = rank_vs_N_MP;
rank_vs_N_MM_all( ( curr_seed - 1 )*num_networks_per_seed + 1:curr_seed*num_networks_per_seed, : ) = rank_vs_N_MM;
rank_vs_N_SIS_all( ( curr_seed - 1 )*num_networks_per_seed + 1:curr_seed*num_networks_per_seed, : ) = rank_vs_N_SIS;
rank_vs_N_kuramoto_all( ( curr_seed - 1 )*num_networks_per_seed + 1:curr_seed*num_networks_per_seed, : ) = rank_vs_N_kuramoto;
rank_vs_N_cw_all( ( curr_seed - 1 )*num_networks_per_seed + 1:curr_seed*num_networks_per_seed, : ) = rank_vs_N_cw;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% plot results, corresponding to Fig_S4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%open a new large figure
figure
fig = gcf;
fig.Units = 'normalized';
fig.OuterPosition = [ 0 0 1 1 ];
plot( N_all, mean( rank_vs_N_LV_all, 1 ))
hold
plot( N_all, mean( rank_vs_N_MP_all, 1 ))
plot( N_all, mean( rank_vs_N_MM_all, 1 ))
plot( N_all, mean( rank_vs_N_SIS_all, 1 ))
plot( N_all, mean( rank_vs_N_kuramoto_all, 1 ))
plot( N_all, mean( rank_vs_N_cw_all, 1 ))
legend( 'Lotka-Volterra', 'Mutualistic population', 'Michaelis-Menten', 'SIS', 'Kuramoto', 'Cowan-Wilson')
end