-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup20190213saveresult.m
528 lines (478 loc) · 22.7 KB
/
backup20190213saveresult.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
%Weilei Zeng 08/06/2018
%plot the result of simulations
%control switch inside draw_code()
%draw_code()
%saveTwo()
run_save_more_circuit() %phenomenological model C, circuit model
%run_save_more() %for phenomenological A and B, sumer simulation
%update_plots() %update for model A and model B
%system('./sync_to_macbook_weilei.sh')
function saveTwo()
flag=23;
column_index=[5,5];%2 for pm, 5 for lifetime;7 for pq
switch flag
case 1
% a standard compare between repeat and convolutional
filename1='data/circuit/code1/simulationRepeatCircuitRepeat7model-a-soft-1test.mat';
filename2='data/circuit/code1/simulationCircuit9model-a-hard-3-1.mat';
legends = {'repeat';'convolutional'};
timesteps=[10 37];
filename='data/circuit/code1/repeat_vs_convolutional.mat' %title
end
%save the figure directly without display it.
fig=figure('visible','off');
hold on
load(filename1);
plots(1)=plot(log10(table(:,2)),log10(table(:,column_index(1)))+log10(timesteps(1)),'-o'); %plot life_time*timesteps
load(filename2);
plots(2)=plot(log10(table(:,2)),log10(table(:,column_index(2)))+log10(timesteps(2)),'-*'); %plot life_time*timesteps
hold off
legend(plots,legends);
title(filename);
label(2)
saveas(fig,[filename(1:end-4),'.fig'],'fig')
saveas(fig,[filename(1:end-4),'.png'],'png')
saveas(fig,[filename(1:end-4),'.pdf'],'pdf')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function run_save_more_circuit()
%what is going to plot: for the circuit error model (1)GA (2)GI (3)G (no G decoder in this case)
file_version_flag=2;
switch file_version_flag
case 1 %phenomenological model A
% file_version='-A-soft-1-1';
file_version='-A-soft-3-1'; % run14
file_version_GA=['-GA',file_version];
% file_version='-A-soft-1-1'; %ok
% file_version='-A-soft-1-2'; %good 600sec
file_version_GI=['-GI',file_version];
folder_plots='data/circuit/plots/circuit_A';
case 2 %phenomenological model B
file_version='-B-soft-3-1'; % run14
file_version='-B-soft-4-1'; % run14
%file_version='-soft-1-3'; %good B 600sec
% file_version='-B-soft-1-2';% not good 600sec need: 3600sec
% file_version='-B-soft-3-1'; %
file_version_GA=['-GA',file_version];
% file_version='-soft-2-2';%B best fix pq
% file_version='-B-soft-1-1'; %good 600sec
% file_version='-B-soft-2-1'; %
file_version_GI=['-GI',file_version];
% folder_plots='data/circuit/plots/circuit_B';
folder_plots='data/circuit/plots/model_C';
end
%reserve filenames other than filename for multiple curces
filenames_GI={['data/circuit/code1/simulationRepeatCircuitRepeat7model-a',file_version_GI,'.mat']};
filenames_GA={['data/circuit/code1/simulationCircuit9model-a',file_version_GA,'.mat']};
% 'data/circuit/code1/simulationRepeatCircuitRepeat7model-a-GI-soft-1-1.mat'
% folder_plots='data/circuit/plots/circuit';
system(['mkdir ',folder_plots])%
if nargin == 0 %if no default input
flag=99;
end
switch flag
case 101 %101
filename=[folder_plots,'/circuit-GA.mat'];
filenames=filenames_GA;
legends={'GA'}
% legends={'GA: $p_s=p_q$';'GA: $p_s=p_q/10$';'GA: $p_s=10p_q$'}
timesteps=[1];
case 102 %102
filename=[folder_plots,'/circuit-GI.mat'];
filenames=filenames_GI;
legends={'GI'}
% legends={'GA: $p_s=p_q$';'GA: $p_s=p_q/10$';'GA: $p_s=10p_q$'}
timesteps=[1];
case 110 %110
filename=[folder_plots,'/circuit-GA-vs-GI.mat'];
% filename=[folder_plots,'/circuit-lifetime-GA-vs-GI.mat'];
filenames=[filenames_GA,filenames_GI];
legends={'GA';'GI'}
% legends={'GA: $p_s=p_q$';'GA: $p_s=p_q/10$';'GA: $p_s=10p_q$'}
timesteps=[1 1];
case 99 %201 plot lifetime*time steps
filename=[folder_plots,'/circuit-GA-vs-GI.mat'];
% filename=[folder_plots,'/circuit-lifetime-GA-vs-GI.mat'];
filenames=[filenames_GA,filenames_GI];
legends={'GA';'GI'}
% legends={'GA: $p_s=p_q$';'GA: $p_s=p_q/10$';'GA: $p_s=10p_q$'}
timesteps=[37 9];
end
pqs=0.5:0.1:3.5;
%filenames'
pqs=0.5:0.1:4.5;
pqs=10.^(-pqs);extraXY=[pqs;pqs];extraName='failure rate = $p_q$';
save_more_circuit(filenames,filename,legends,timesteps,extraXY,extraName);
% save_more_circuit_lifetime(filenames,filename,legends,timesteps,extraXY,extraName);
%save_more_circuit_lifetime(filenames,filename,legends,timesteps);
end
function save_more_circuit(filenames,titleText,legends, timesteps, extraXY,extraName)
%plot p_fail vs p_q
%draw any number of curves, filenames is a cell of filenames
%extraXY is not necessary, reserverd for some calculated bounds.
%get data
length=size(filenames,2); %total number of curves except extraXY
tables=cell(1,length);
for i=1:length
filename = filenames{i};
load(filename,'table');
tables{i} = table;
end
%myfig=figure('pos',[100 400 700 500],'visible','off') %left bottom width height
myfig=figure('pos',[100 400 480 360],'visible','off') %left bottom width height
%fig=figure('visible','off');
hold on
halfLength=ceil(length/2); %devide curve into two groups for different linestyles
for i=1:halfLength
%timesteps is taken care by pq, so timesteps is not needed here
plots(i)=plot(log10(tables{i}(:,7)),log10(tables{i}(:,4)),'-o'); %p_fail vs pq
% plots(i)=plot(log10(tables{i}(:,7)),log10(tables{i}(:,4))+log10(timesteps(i)),'-o'); %p_fail vs pq
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,5))+log10(timesteps(i)),'-o'); %lifetime*timesteps vs pm/pq
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,4))+log10(timesteps(i)),'-o'); %p_fail vs pm/pq
end
for i=(halfLength+1):length
plots(i)=plot(log10(tables{i}(:,7)),log10(tables{i}(:,4)),'--*'); %p_fail vs pq
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,5))+log10(timesteps(i)),'--*');
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,4))+log10(timesteps(i)),'--*');
end
if nargin==6
plots(length+1)=plot(log10(extraXY(1,:)),log10(extraXY(2,:)),':');%-o :
filenames{1,end+1}=extraName;
legends(end+1,1)={extraName};
%plots(length+2)=plot(log10(extraXY(1,:)),log10(extraXY(2,:)*4),':');%-o :
%plots(length+3)=plot(log10(extraXY(1,:)),log10(extraXY(2,:)*5),':');%-o :
%plots(length+4)=plot(log10(extraXY(1,:)),log10(extraXY(2,:)*6),':');%-o :
%legends(end+1,1)={'4p_q'};
%legends(end+1,1)={'5p_q'};
%legends(end+1,1)={'6p_q'};
end
if nargin==2
legends=filenames;
end
filenames'
titleText
legend(plots,legends,'FontSize',8) %11
%legend('Location','southeast')
legend('Location','northwest')
legend('Interpreter','Latex')
title(titleText)
label(4)
hold off
saveas(myfig,[titleText(1:end-4),'.fig'],'fig')
saveas(myfig,[titleText(1:end-4),'.png'],'png')
saveas(myfig,[titleText(1:end-4),'.pdf'],'pdf')
end
function save_more_circuit_lifetime(filenames,titleText,legends, timesteps, extraXY,extraName)
%plot lifetime*timesteps vs p_m
%draw any number of curves, filenames is a cell of filenames
%extraXY is not necessary, reserverd for some calculated bounds.
%get data
length=size(filenames,2); %total number of curves except extraXY
tables=cell(1,length);
for i=1:length
filename = filenames{i};
load(filename,'table');
tables{i} = table;
end
myfig=figure('pos',[100 400 480 360],'visible','off') %left bottom width height
%fig=figure('visible','off');
hold on
% timesteps=[37,9]
halfLength=ceil(length/2); %devide curve into two groups for different linestyles
for i=1:halfLength
%timesteps is taken care by pq, so timesteps is not needed here
%plots(i)=plot(log10(tables{i}(:,7)),log10(tables{i}(:,4)),'-o'); %p_fail vs pq
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,7)),'-.'); % pq vs pm
%plots(i)=plot(log10(tables{i}(:,7)),log10(tables{i}(:,4))+log10(timesteps(i)),'-o'); %p_fail vs pq
plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,5))+log10(timesteps(i)),'-o'); %lifetime*timesteps vs pm
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,4))+log10(timesteps(i)),'-o'); %p_fail vs pm/pq
end
for i=(halfLength+1):length
%plots(i)=plot(log10(tables{i}(:,7)),log10(tables{i}(:,4)),'--*'); %p_fail vs pq
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,7)),'-.'); % pq vs pm
plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,5))+log10(timesteps(i)),'--*');
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,4))+log10(timesteps(i)),'--*');
end
if nargin==6
plots(length+1)=plot(log10(extraXY(1,:)),log10(extraXY(2,:)),':');%-o :
filenames{1,end+1}=extraName;
legends(end+1,1)={extraName};
end
if nargin==2
legends=filenames;
end
filenames'
titleText
legend(plots,legends,'FontSize',8) %11
%legend('Location','southeast')
legend('Location','northeast')
legend('Interpreter','Latex')
title(titleText)
label(2)
hold off
saveas(myfig,[titleText(1:end-4),'.fig'],'fig')
saveas(myfig,[titleText(1:end-4),'.png'],'png')
saveas(myfig,[titleText(1:end-4),'.pdf'],'pdf')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%below part for summer simulations (phenomenological model A
function update_plots()
all=[301,302,303,304,44,31,32,33,41,42,43];
comparisons=[31,32,33,41,42,43];
singles=[301,302,303,304,44];
flags=301;
flags=singles;
for flag=flags
try
run_save_more(flag)
end
end
end
function run_save_more(flag)
%define filenames for data
%GA: code1, simulation678
%GR: GI(GR): code5, simulation678
%GI: GI with majority vote, code1 simulation 7
%G: code1 simulation7, wrong syndrome filter
folder_plots='data/circuit/plots';
%there are four folders under plots/
file_version_flag=6;
%now only use 4(41) and 6
switch file_version_flag
case 1 %decoding failure
file_version_GR='-soft-4-3';
file_version_GA='-soft-2-3'; %waiting
file_version_GI='-soft-2-3';
file_version_G ='-G-soft-2-3';
case 2 %logical failure
file_version_GR='-soft-5-1'; %logical failure
file_version_GA='-soft-3-1'; %logical failure
file_version_GI='-soft-3-1'; %logical failure
file_version_G ='-G-soft-3-1'; %logical failure
% file_version_GA='-soft-3-2'; %logical failure
case 3
% a change for range of small pq
file_version='-soft-7-1';
file_version_GA=file_version;
file_version_GR=file_version;
file_version='-soft-7-2';
file_version_GI=file_version;
file_version_G=['-G',file_version];
case 4
% folder_plots='data/circuit/plots/summer_A';
folder_plots='data/circuit/plots/model_A';
%phenomenological model A, case/model e,g,f
%file_version='-soft-7-3'; %test data
file_version='-soft-7-4'; %wider range than case 2. dataRunTime=600
file_version_GR=file_version;
file_version_GI=file_version;
file_version_G=['-G',file_version];
file_version='-soft-7-2'; % more data, dataRunTime=1800
%supposed to be 7-4-1,but I put it to 7-2, luckily didn't tuin other data
file_version_GA=file_version;
%result: saved in plots/logical_failure2/. results are expected, except for mode g, the curve is not smooth, may rerun and update later.
case 41 %compared to 4, we add name for '-A' in file version
%since model A for circuit is a fake model, I never run this simulation.
folder_plots='data/circuit/plots/model_A';
%phenomenological model A, case/model e,g,f
file_version='-A-soft-1-1'; %test data
file_version_GR=file_version;
file_version_GI=file_version;
file_version_G=['-G',file_version];
file_version_GA=file_version;
case 5 %outdated
%i dont see any difference from case 6
%folder_plots='data/circuit/plots/phenomenological-model-B';
% folder_plots='data/circuit/plots/summer_A';
%phenomenological model B, circuit model only GA and GI code , saved in plots/phenomenological-model-B
file_version='-B-soft-1-1';
file_version_GR=file_version;
file_version_GI=file_version;
file_version_G=['-G',file_version];
file_version_GA=file_version;
%result: saved in plots/logical_failure2/. results are expected, except for mode g, the curve is not smooth, may rerun and update later.
% file_version_GA=['-GA',file_version];
%file_version_GR=['-GR',file_version];
%file_version_GI=['-GI',file_version];
%file_version_G=['-G',file_version];
case 6
%phenomenological model B, case/model e,g,f
% folder_plots='data/circuit/plots/summer_B';
folder_plots='data/circuit/plots/model_B';
file_version='-B-soft-1-3'; %best data
file_version='-B-soft-2-3'; %okay data, 60 sec, need run 600 sec
file_version='-B-soft-2-4'; %600 sec waiting
file_version_GA=file_version;
file_version_GR=file_version;
file_version_GI=file_version;
file_version_G=['-G',file_version];
end
if nargin == 0 %if no default input
flag=99;
end
filenames_GR = {...
['data/circuit/code5/simulation678-repeat9model-e',file_version_GR,'.mat'],...
['data/circuit/code5/simulation678-repeat9model-f',file_version_GR,'.mat'],...
['data/circuit/code5/simulation678-repeat9model-g',file_version_GR,'.mat']};
%GR: -soft-3-2
filenames_GA = {...
['data/circuit/code1/simulation678-repeat9model-e',file_version_GA,'.mat'],...
['data/circuit/code1/simulation678-repeat9model-f',file_version_GA,'.mat'],...
['data/circuit/code1/simulation678-repeat9model-g',file_version_GA,'.mat']};
%GA: -soft-1-3
filenames_GI = {...
['data/circuit/code1/simulation7-repeat7model-e',file_version_GI,'.mat'],...
['data/circuit/code1/simulation7-repeat7model-f',file_version_GI,'.mat'],...
['data/circuit/code1/simulation7-repeat7model-g',file_version_GI,'.mat']};
%GI: -soft-1-5
filenames_G = {...
['data/circuit/code1/simulation7-repeat7model-e',file_version_G,'.mat'],...
['data/circuit/code1/simulation7-repeat7model-f',file_version_G,'.mat'],...
['data/circuit/code1/simulation7-repeat7model-g',file_version_G,'.mat']};
%G: -G-soft-1-2
switch flag
case 301
filename=[folder_plots,'/GA.mat'];
filenames=filenames_GA;
legends={'GA: $p_s=p_q$';'GA: $p_s=p_q/10$';'GA: $p_s=10p_q$'};
timesteps=[1 1 1];
pqs=0.5:0.1:3.5;
case 302
filename=[folder_plots,'/GR.mat'];
filenames=filenames_GR;
legends={'GR: $p_s=p_q$';'GR: $p_s=p_q/10$';'GR: $p_s=10p_q$'};
timesteps=[1 1 1];
pqs=0.5:0.1:3.5;
case 303
filename=[folder_plots,'/GI.mat'];
filenames=filenames_GI;
legends={'GI: $p_s=p_q$';'GI: $p_s=p_q/10$';'GI: $p_s=10p_q$'};
timesteps=[1 1 1];
pqs=0.5:0.1:3.5;
case 304
filename=[folder_plots,'/G.mat'];
filenames=filenames_G;
legends={'G: $p_s=p_q$';'G: $p_s=p_q/10$';'G: $p_s=10p_q$'};
timesteps=[1 1 1];
pqs=0.5:0.1:3.5;
case 31 %31 GR vs GA
filename=[folder_plots,'/GR-vs-GA.mat'];
filenames=[filenames_GR,filenames_GA];
legends={'GR: $p_s=p_q$';'GR: $p_s=p_q/10$';'GR: $p_s=10p_q$';...
'GA: $p_s=p_q$';'GA: $p_s=p_q/10$';'GA: $p_s=10p_q$'}
timesteps=[1 1 1 1 1 1];
pqs=0.5:0.1:3.5;
case 32 % GR vs GI
filename=[folder_plots,'/GR-vs-GI.mat'];
filenames=[filenames_GR,filenames_GI];
legends={'GR: $p_s=p_q$';'GR: $p_s=p_q/10$';'GR: $p_s=10p_q$';...
'GI: $p_s=p_q$';'GI: $p_s=p_q/10$';'GI: $p_s=10p_q$'}
timesteps=[1 1 1 1 1 1];
pqs=0.5:0.1:3.5;
case 33 %G vs GI
filename=[folder_plots,'/G-vs-GI.mat'];
filenames=[filenames_G,filenames_GI];
legends={'G: $p_s=p_q$';'G: $p_s=p_q/10$';'G: $p_s=10p_q$';...
'GI: $p_s=p_q$';'GI: $p_s=p_q/10$';'GI: $p_s=10p_q$'}
timesteps=[1 1 1 1 1 1];
pqs=0.5:0.1:3.5;
case 41 % mode e four decoder
filename=[folder_plots,'/four-decoder-model-e.mat'];
filenames=[filenames_GA(1),filenames_GR(1),filenames_GI(1),filenames_G(1)];
legends={'GA';'GR';'GI';'G'};
timesteps=[1 1 1 1];
pqs=0.5:0.1:3.5;
case 42 % mode f four decoder
filename=[folder_plots,'/four-decoder-model-f.mat'];
filenames=[filenames_GA(2),filenames_GR(2),filenames_GI(2),filenames_G(2)];
legends={'GA';'GR';'GI';'G'};
timesteps=[1 1 1 1];
pqs=0.5:0.1:3.5;
case 43 % mode g four decoder
filename=[folder_plots,'/four-decoder-model-g.mat'];
filenames=[filenames_GA(3),filenames_GR(3),filenames_GI(3),filenames_G(3)];
legends={'GA';'GR';'GI';'G'};
timesteps=[1 1 1 1];
pqs=1.5:0.1:3.5;
case 44 % four decoder mode efg
filename=[folder_plots,'/four-decoder.mat'];
filenames=[filenames_GA,filenames_GR,filenames_GI,filenames_G];
% legends={'GA';'GR';'GI';'G'};
legends={'GA: $p_s=p_q$';'GA: $p_s=p_q/10$';'GA: $p_s=10p_q$';...
'GR: $p_s=p_q$';'GR: $p_s=p_q/10$';'GR: $p_s=10p_q$';...
'GI: $p_s=p_q$';'GI: $p_s=p_q/10$';'GI: $p_s=10p_q$';...
'G: $p_s=p_q$';'G: $p_s=p_q/10$';'G: $p_s=10p_q$'}
timesteps=[1 1 1 1 1 1 1 1 1 1 1 1];
pqs=0.5:0.1:3.5;
end
filenames';
pqs=0.5:0.1:4.5;
pqs=10.^(-pqs);extraXY=[pqs;pqs];extraName='failure rate = $p_q$';
save_more(filenames,filename,legends,timesteps,extraXY,extraName);
%the remained part of this function can be deleted Feb 9
%save_more(filenames,filename,legends,timesteps);
%save_more(filenames,filename,legends,timesteps,extraXY,extraName);
end
function save_more(filenames,titleText,legends, timesteps, extraXY,extraName)
%draw any number of curves, filenames is a cell of filenames
%extraXY is not necessary, reserverd for some calculated bounds.
%get data
length=size(filenames,2);
tables=cell(1,length);
for i=1:length
filename = filenames{i};
load(filename,'table');
tables{i} = table;
end
%myfig=figure('pos',[100 400 700 500],'visible','off') %left bottom width height
myfig=figure('pos',[100 400 480 360],'visible','off'); %left bottom width height
%fig=figure('visible','off');
hold on
halfLength=ceil(length/2);
for i=1:halfLength
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,5))+log10(timesteps(i)),'-o');
plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,4))+log10(timesteps(i)),'-o');
end
for i=(halfLength+1):length
%plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,5))+log10(timesteps(i)),'--*');
plots(i)=plot(log10(tables{i}(:,2)),log10(tables{i}(:,4))+log10(timesteps(i)),'--*');
end
if nargin==6
plots(length+1)=plot(log10(extraXY(1,:)),log10(extraXY(2,:)),':');%-o :
filenames{1,end+1}=extraName;
legends(end+1,1)={extraName};
end
if nargin==2
legends=filenames;
end
filenames'
titleText
legend(plots,legends,'FontSize',8) %11
%legend('Location','southeast')
legend('Location','northwest')
legend('Interpreter','Latex')
title(titleText)
label(4)
hold off
saveas(myfig,[titleText(1:end-4),'.fig'],'fig')
saveas(myfig,[titleText(1:end-4),'.png'],'png')
saveas(myfig,[titleText(1:end-4),'.pdf'],'pdf')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This function shares by many plots
function label(label_flag)
switch label_flag
case 1 % p_fail and qubit error prob
xlabel('qubit error probability pq (log10)')
ylabel('rate of decoding failure (log10)')
case 2 %lifetime * timesteps
xlabel('error probability on each time step (log10)','Interpreter','Latex')
ylabel('lifetime $\times$ timesteps (log10)','Interpreter','Latex');
case 3 % p_fail and input error prob
xlabel('Input error probability pm (log10)')
ylabel('rate of decoding failure (log10)')
case 4 % logical failure in Latex
xlabel('qubit error probability $p_q$ $(log_{10})$','Interpreter','Latex')
ylabel('rate of logical failure ($log_{10}$)','Interpreter','Latex')
end
end