-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFig3EF.m
346 lines (301 loc) · 12.4 KB
/
Fig3EF.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
current_dir=cd;
%assumed activation from the main directory, where this script is found in
addpath(horzcat(current_dir,'\Data\Fig3EF'));
time_Factor=4*10^-7; %michael add, the protein diffusion time scaling
% cd('C:\Users\admin\Documents\RMFO\LoopaUP_1_time_0_85_amp\3_4\0\07_28_2024_12_51_07_Js_3_4_Mu_0_Y_Beast_1_time_0_85_ampY_control_folder_num_0_job_id_9018968\2\9');
load('tot_energy_mu_0.0_energy_0.0_run_num_1_total_num_target_2.mat');
Total_energy=foo;
load('beast_cp_mu_0.0_energy_0.0_run_num_1_total_num_target_2.mat');
CP=foo;
cp=CP(:,1);
End_time=max(CP(:,4))*time_Factor;
load('mini_times_vec_mu_0.0_energy_0.0_run_num_1_total_num_target_2.mat');
time_o=foo;
%Fig3 for the paper
bumm=2*10^6;
fcc=2*10^7/bumm;
IL=1:1:2*10^7;
ILL=1:1*fcc:2*10^7;
% time_o=pivot4.foo;
time= time_o(:,1)*time_Factor;
Aop=cumsum(time);
CCp=Aop(end);
load('mini_summed_distance_UP_vec_mu_0.0_energy_0.0_run_num_1_total_num_target_2.mat');
cd(current_dir);
Distance=foo;
qqqqq=Distance;
Distance=Distance(IL,:);
Aop2=Aop(IL);
% Original vector
x = Aop2;
% Sort the vector to make handling duplicates easier
x_sorted = sort(x);
% Define a very small number
epsilon = 1e-10;
% Loop through the sorted vector to add a small number to duplicates
for i = 2:length(x_sorted)
if x_sorted(i) == x_sorted(i-1)
x_sorted(i) = x_sorted(i) + epsilon;
epsilon = epsilon * 10; % Increase the small number for next duplicates
end
end
Aop2=x_sorted;
Total_energy2=interp1(Aop2, Total_energy,0:CCp/bumm:(CCp-CCp/bumm));
% Distance(:,1)
SSSS=interp1(Aop2, single(Distance(:,1)),0:CCp/bumm:(CCp-CCp/bumm));
SSSS2=interp1(Aop2, single(Distance(:,2)),0:CCp/bumm:(CCp-CCp/bumm));
timi=0:CCp/bumm:CCp;
Distance=[int32(SSSS); int32(SSSS2)]';
Total_energy2(1)=0;
Distance(1,1)=qqqqq(1,1);
Distance(1,2)=qqqqq(1,2);
Aop22=Aop2(ILL);
Time=0:CCp/bumm:(CCp-CCp/bumm); % the factor 4 is because of how the vector is itnerpolated
% Total_energy=o.data;
% load('Total_energy2.mat');
% cp=sort(o.trend.cp(1:o.trend.ncp_median));
% trend=o.trend.slp;
gg=figure;
yyaxis left
bbb=get(gg,'Position');
h_factor=bbb(3)/bbb(4);
new_width=0.8*8.7;
set(gg, 'Units', 'centimeters', 'Position',[2 2 new_width 0.5*new_width]);
if sum(isnan(cp))~=0
cp=cp(1:(find (isnan(cp),1)-1));
end
cp=[1 ;cp];
%taking the first one as well
% cp=[1;cp];
if ~isempty(find (cp==0))
cp=cp(find (cp~=0));
end
% noisy_signal = awgn(Total_energy, snr, 'measured');
plot(Time,Total_energy2);
ylimits=ylim;
hold on;
% L=(find(Distance(:,1)==0,1))*10^3;
% cps=cp(cp<(min(find(Distance(:,2)==0,1),find(Distance(:,1)==0,1)))*fcc);
cps=cp;
ylim([-120 -60]);
ylimits=ylim;
%for i = 1 : length(cps)
%plot( [cp(i),cp(i)]*10000, get(gca,'Ylim'),'color',[0.8500 0.3250 0.0980]);
%plot( [cp(i),cp(i)]*10000, get(gca,'Ylim'),'color',[0.8500 0.3250 0.0980]);
xxxxx=Aop2(ceil((cps)));
s=scatter(xxxxx,(ylimits(1)+3).*ones(1,length(xxxxx)),[],[0.8500 0.3250 0.0980],"|",'filled','MarkerEdgeColor',[0.8500 0.3250 0.0980]);
s.SizeData = 20;
% s=scatter(Aop2(ceil((cp(i)))),ylimits(1)+3,[],[0.8500 0.3250 0.0980],"|",'filled','MarkerEdgeColor',[0.8500 0.3250 0.0980]);
% s.SizeData = 20;
%xlim([0 2000]*10000);
%ylabel('$E$\ $[K_{B}T]$','Interpreter','latex');
% ylabel( '{\boldmath${E$\ $[K_{B}T]}$}','Interpreter','latex')
ylabel( '{\boldmath${E\ [k_{B}T]}$}','Interpreter','latex')
% xx0=xlabel('Time [Cs]');
xx0= xlabel( '{\boldmath${Time\ [s]}$}','Interpreter','latex');
% xx0.Position=xx0.Position-[0 10 0];
% ylim([min(Total_energy)-10 0])
xlim([0 Time(end)])
%end
xlim([ 22500*time_Factor 23440*time_Factor+300*time_Factor]);
% xlim([Time(ceil((cps(end-25)/fcc))) Time(2317)*fcc]);
set(gca,'FontSize',6);
yyaxis right
Trend=CP(:,7);
time_for_trend2=CP(:,3)*time_Factor;
time_for_trend2=time_for_trend2(time_for_trend2>0);
Trend=Trend(time_for_trend2>0);
yaks=find(time_for_trend2<(23440+8200)*time_Factor);
time_for_trend=time_for_trend2(yaks);
Trend=Trend(yaks);
times=time_for_trend; trend_values=Trend/time_Factor;time_durations = diff(time_for_trend); % Difference between consecutive time points
% Initialize time axis and square wave
times=[0; times];
total_time = times(end); % The total time span from the first to the last time point
time_axis = times(1):time_Factor:total_time; % A finer time axis for smooth plotting
square_wave = zeros(1, length(time_axis)); % Initialize the square wave
% Fill the square wave based on trend values and time intervals
current_time_index = 1;
trend_values(269)=-0.0003/time_Factor;
for i = 1:length(trend_values)-1
% Find the time indices that correspond to the current time interval
time_indices = time_axis >= times(i) & time_axis < times(i+1);
% Assign the trend value to the corresponding time interval
square_wave(time_indices) = trend_values(i);
end
% The last segment: fill in the last trend value until the last time
% square_wave(time_axis >= times(end-1)) = trend_values(end);
plot(time_axis, square_wave,'k');
xlim([ 22500*time_Factor 23440*time_Factor+300*time_Factor]);
ylim([-3 0.5]/time_Factor);
pp=ylim;
ax=gca;
xgca=gca;
ax.YAxis(2).Color = 'k';
set(gca, 'Position',[0.1300 0.2214 0.7338 0.7036]);
ylabel( '{\boldmath${\ Trend\ [{k_{B}T}\cdot{s^{-1}}]}$}','Interpreter','latex')
xgca.Position= [0.1700+0.08 0.2214 0.7338-0.18 0.7036];
xgca.Units = 'pixels';
xgca.Position= [29.6000+10 25.3540+10 145.7720 72.1600];
% [42.0960 24.2650 145.7720 72.1600]
DOGG='Fig3_maxime';
print (DOGG,'-dpng','-r300');
%Subfigure after control activated
gg=figure;
yyaxis left
bbb=get(gg,'Position');
h_factor=bbb(3)/bbb(4);
new_width=8.7;
set(gg, 'Units', 'centimeters', 'Position',[2 2 0.5*new_width 0.5*new_width]);
if sum(isnan(cp))~=0
cp=cp(1:(find (isnan(cp),1)-1));
end
cp=[1 ;cp];
%taking the first one as well
% cp=[1;cp];
if ~isempty(find (cp==0))
cp=cp(find (cp~=0));
end
% noisy_signal = awgn(Total_energy, snr, 'measured');
plot(Time,Total_energy2);
ylimits=ylim;
hold on;
% L=(find(Distance(:,1)==0,1))*10^3;
% cps=cp(cp<(min(find(Distance(:,2)==0,1),find(Distance(:,1)==0,1)))*fcc);
cps=cp;
ylim([-150 -20]);
ylimits=ylim;
for i = 1 : length(cps)
%plot( [cp(i),cp(i)]*10000, get(gca,'Ylim'),'color',[0.8500 0.3250 0.0980]);
s=scatter(Aop2(ceil((cp(i)))),ylimits(1)+7,[],[0.8500 0.3250 0.0980],"|",'filled','MarkerEdgeColor',[0.8500 0.3250 0.0980]);
s.SizeData = 20;
%xlim([0 2000]*10000);
%ylabel('$E$\ $[K_{B}T]$','Interpreter','latex');
% ylabel( '{\boldmath${E$\ $[K_{B}T]}$}','Interpreter','latex')
ylabel( '{\boldmath${E\ [k_{B}T]}$}','Interpreter','latex')
% xx0=xlabel('Time [Cs]');
xx0= xlabel( '{\boldmath${Time\ [s]}$}','Interpreter','latex');
% xx0.Position=xx0.Position-[0 10 0];
% ylim([min(Total_energy)-10 0])
xlim([0 Time(end)*time_Factor])
end
% xlim([Time(ceil((cps(end-25)/fcc))) Time(2317)*fcc]);
set(gca,'FontSize',6);
yyaxis right
Trend=CP(:,7);
[I,M]=find(Total_energy2<-135,1);
last_time=Time(M);
time_for_trend2=CP(:,3)*time_Factor;
time_for_trend2=time_for_trend2(time_for_trend2>0);
Trend=Trend(time_for_trend2>0);
yaks=find(time_for_trend2<last_time+2300);
time_for_trend=time_for_trend2(yaks);
Trend=Trend(yaks);
times=time_for_trend; trend_values=Trend/time_Factor;time_durations = diff(time_for_trend); % Difference between consecutive time points
% Initialize time axis and square wave
times=[0; times];
total_time = times(end); % The total time span from the first to the last time point
time_axis = times(1):time_Factor:total_time; % A finer time axis for smooth plotting
square_wave = zeros(1, length(time_axis)); % Initialize the square wave
% Fill the square wave based on trend values and time intervals
current_time_index = 1;
trend_values(269)=-0.0003/time_Factor;
for i = 1:length(trend_values)
% Find the time indices that correspond to the current time interval
time_indices = time_axis >= times(i) & time_axis < times(i+1);
% Assign the trend value to the corresponding time interval
square_wave(time_indices) = trend_values(i);
end
% The last segment: fill in the last trend value until the last time
% square_wave(time_axis >= times(end-1)) = trend_values(end);
yyaxis right
plot(time_axis, square_wave,'k');
xlim([ 22500*time_Factor last_time+300*time_Factor]);
ylim([-3 0.5]/time_Factor);
pp=ylim;
ax=gca;
ax.YAxis(2).Color = 'k';
set(gca, 'Position',[0.1300 0.2214 0.7338 0.7036]);
ylabel( '{\boldmath${\ Trend\ [{k_{B}T}\cdot{s^{-1}}]}$}','Interpreter','latex')
ax.Position= [0.1700+0.08 0.2214 0.7338-0.18 0.7036];
DOGG='Fig3_maxime_after_shock';
print (DOGG,'-dpng','-r300');
gg=figure;
yyaxis left
bbb=get(gg,'Position');
h_factor=bbb(3)/bbb(4);
new_width=8.7;
set(gg, 'Units', 'centimeters', 'Position',[2 2 1*new_width 0.5*new_width]);
if sum(isnan(cp))~=0
cp=cp(1:(find (isnan(cp),1)-1));
end
cp=[1 ;cp];
%taking the first one as well
% cp=[1;cp];
if ~isempty(find (cp==0))
cp=cp(find (cp~=0));
end
% noisy_signal = awgn(Total_energy, snr, 'measured');
plot(Time,Total_energy2);
ylimits=ylim;
hold on;
% L=(find(Distance(:,1)==0,1))*10^3;
% cps=cp(cp<(min(find(Distance(:,2)==0,1),find(Distance(:,1)==0,1)))*fcc);
cps=cp;
ylim([-150 0]);
ylimits=ylim;
for i = 1 : length(cps)
%plot( [cp(i),cp(i)]*10000, get(gca,'Ylim'),'color',[0.8500 0.3250 0.0980]);
s=scatter(Aop2(ceil((cp(i)))),ylimits(1)+7,[],[0.8500 0.3250 0.0980],"|",'filled','MarkerEdgeColor',[0.8500 0.3250 0.0980]);
s.SizeData = 20;
%xlim([0 2000]*10000);
%ylabel('$E$\ $[K_{B}T]$','Interpreter','latex');
% ylabel( '{\boldmath${E$\ $[K_{B}T]}$}','Interpreter','latex')
ylabel( '{\boldmath${E\ [k_{B}T]}$}','Interpreter','latex')
% xx0=xlabel('Time [Cs]');
xx0= xlabel( '{\boldmath${Time\ [s]}$}','Interpreter','latex');
% xx0.Position=xx0.Position-[0 10 0];
% ylim([min(Total_energy)-10 0])
xlim([0 Time(end)])
end
% xlim([ 0 last_time]);
% xlim([Time(ceil((cps(end-25)/fcc))) Time(2317)*fcc]);
set(gca,'FontSize',6);
yyaxis right
Trend=CP(:,7);
time_for_trend2=CP(:,3)*time_Factor;
time_for_trend2=time_for_trend2(time_for_trend2>0);
Trend=Trend(time_for_trend2>0);
yaks=find(time_for_trend2<last_time+5300*time_Factor);
time_for_trend=time_for_trend2(yaks);
Trend=Trend(yaks);
times=time_for_trend; trend_values=Trend/time_Factor;time_durations = diff(time_for_trend); % Difference between consecutive time points
% Initialize time axis and square wave
times=[0; times];
total_time = times(end); % The total time span from the first to the last time point
time_axis = times(1):time_Factor:total_time; % A finer time axis for smooth plotting
square_wave = zeros(1, length(time_axis)); % Initialize the square wave
% Fill the square wave based on trend values and time intervals
current_time_index = 1;
trend_values(269)=-0.0003/time_Factor;
for i = 1:length(trend_values)-1
% Find the time indices that correspond to the current time interval
time_indices = time_axis >= times(i) & time_axis < times(i+1);
% Assign the trend value to the corresponding time interval
square_wave(time_indices) = trend_values(i);
end
% The last segment: fill in the last trend value until the last time
% square_wave(time_axis >= times(end-1)) = trend_values(end);
xlim([ 0 last_time+5300*time_Factor]);
plot(time_axis, square_wave,'k');
% xlim([ 22500 23440]*time_Factor);
% ylim([-8 1.5]/time_Factor);
% pp=ylim;
ax=gca;
xgca=gca;
ax.YAxis(2).Color = 'k';
set(gca, 'Position',[0.1300 0.2214 0.7338 0.7036]);
ylabel( '{\boldmath${\ Trend\ [{k_{B}T}\cdot{s^{-1}}]}$}','Interpreter','latex')
% xgca.Position= [0.1700+0.08 0.2214 0.7338-0.18 0.7036];
DOGG='Fig3_up;_to_assembly';
print (DOGG,'-dpng','-r300');