-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_data_1par.m
72 lines (61 loc) · 3.34 KB
/
save_data_1par.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
function save_data_1par(namepar, contpar, file_id, N, branchpoints, nunst_stst, par_list, freq_list, T_list, amp_list, max_list, min_list)
% branchpoints = stst_branch_wbifs.point
if namepar=='N'
file_name_stationary = sprintf('./results/data/N/bf_stationary.txt');
file_name_periodic = sprintf('./results/data/N/bf_periodic.txt');
file_name_bfpt = sprintf('./results/data/N/bf_bfpt.txt');
% Save the stationary branch
f_bf = fopen(file_name_stationary, 'w');
for i=1:length(branchpoints)
fprintf(f_bf, '%.9g %.9g %.9g %.9g %.9g %.9g\n', branchpoints(i).parameter(contpar), branchpoints(i).x(1), branchpoints(i).x(2), branchpoints(i).x(3), branchpoints(i).x(4), nunst_stst(i));
end
fclose(f_bf);
% Save the periodic branch
f_bf = fopen(file_name_periodic, 'w');
for i=1:length(par_list)
fprintf(f_bf, '%.9g %.9g %.9g ', par_list(i), freq_list(i), T_list(i));
fprintf(f_bf, '%.9g %.9g %.9g %.9g ', amp_list(i,1), amp_list(i,2), amp_list(i,3), amp_list(i,4));
fprintf(f_bf, '%.9g %.9g %.9g %.9g ', max_list(i,1), max_list(i,2), max_list(i,3), max_list(i,4));
fprintf(f_bf, '%.9g %.9g %.9g %.9g', min_list(i,1), min_list(i,2), min_list(i,3), min_list(i,4));
fprintf(f_bf, '\n');
end
fclose(f_bf);
% Save the bifurcation points
f_bf = fopen(file_name_bfpt, 'w');
for i=1:length(branchpoints)
if ~isempty(branchpoints(i).flag) && strcmp(branchpoints(i).flag,'hopf')
fprintf(f_bf, '%.9g %.9g %.9g %.9g %.9g\n', branchpoints(i).parameter(contpar), branchpoints(i).x(1), branchpoints(i).x(2), branchpoints(i).x(3), branchpoints(i).x(4));
end
end
fclose(f_bf);
else
% Each file_id corresponds to a different N.
file_name_stationary = sprintf('./results/data/%s/bf_stationary_%d.txt', namepar, file_id);
file_name_periodic = sprintf('./results/data/%s/bf_periodic_%d.txt', namepar, file_id);
file_name_bfpt = sprintf('./results/data/%s/bf_bfpt_%d.txt', namepar, file_id);
f_bf = fopen(file_name_stationary, 'w');
fprintf(f_bf, '%g\n', N);
for i=1:length(branchpoints)
fprintf(f_bf, '%.9g %.9g %.9g %.9g %.9g %.9g\n', branchpoints(i).parameter(contpar), branchpoints(i).x(1), branchpoints(i).x(2), branchpoints(i).x(3), branchpoints(i).x(4), nunst_stst(i));
end
fclose(f_bf);
f_bf = fopen(file_name_periodic, 'w');
fprintf(f_bf, '%g\n', N);
for i=1:length(par_list)
fprintf(f_bf, '%.9g %.9g %.9g ', par_list(i), freq_list(i), T_list(i));
fprintf(f_bf, '%.9g %.9g %.9g %.9g ', amp_list(i,1), amp_list(i,2), amp_list(i,3), amp_list(i,4));
fprintf(f_bf, '%.9g %.9g %.9g %.9g ', max_list(i,1), max_list(i,2), max_list(i,3), max_list(i,4));
fprintf(f_bf, '%.9g %.9g %.9g %.9g', min_list(i,1), min_list(i,2), min_list(i,3), min_list(i,4));
fprintf(f_bf, '\n');
end
fclose(f_bf);
f_bf = fopen(file_name_bfpt, 'w');
fprintf(f_bf, '%g\n', N);
for i=1:length(branchpoints)
if ~isempty(branchpoints(i).flag) && strcmp(branchpoints(i).flag,'hopf')
fprintf(f_bf, '%.9g %.9g %.9g %.9g %.9g\n', branchpoints(i).parameter(contpar), branchpoints(i).x(1), branchpoints(i).x(2), branchpoints(i).x(3), branchpoints(i).x(4));
end
end
fclose(f_bf);
end
end