-
Notifications
You must be signed in to change notification settings - Fork 3
/
PAPR_GUI.m
712 lines (539 loc) · 28 KB
/
PAPR_GUI.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
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
function varargout = PAPR_GUI(varargin)
% PAPR_GUI MATLAB code for PAPR_GUI.fig
% PAPR_GUI, by itself, creates a new PAPR_GUI or raises the existing
% singleton*.
%
% H = PAPR_GUI returns the handle to a new PAPR_GUI or the handle to
% the existing singleton*.
%
% PAPR_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PAPR_GUI.M with the given input arguments.
%
% PAPR_GUI('Property','Value',...) creates a new PAPR_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before PAPR_GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to PAPR_GUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help PAPR_GUI
% Last Modified by GUIDE v2.5 02-May-2018 22:27:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PAPR_GUI_OpeningFcn, ...
'gui_OutputFcn', @PAPR_GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before PAPR_GUI is made visible.
function PAPR_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to PAPR_GUI (see VARARGIN)
% Choose default command line output for PAPR_GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes PAPR_GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
addpath('Module')
addpath('Control')
addpath('View')
% --- Outputs from this function are returned to the command line.
function varargout = PAPR_GUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in pop_QAM.
function pop_QAM_Callback(hObject, eventdata, handles)
% hObject handle to pop_QAM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns pop_QAM contents as cell array
% contents{get(hObject,'Value')} returns selected item from pop_QAM
% --- Executes during object creation, after setting all properties.
function pop_QAM_CreateFcn(hObject, eventdata, handles)
% hObject handle to pop_QAM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_Length_Callback(hObject, eventdata, handles)
% hObject handle to txt_Length (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_Length as text
% str2double(get(hObject,'String')) returns contents of txt_Length as a double
% --- Executes during object creation, after setting all properties.
function txt_Length_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_Length (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in pop_Size.
function pop_Size_Callback(hObject, eventdata, handles)
% hObject handle to pop_Size (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns pop_Size contents as cell array
% contents{get(hObject,'Value')} returns selected item from pop_Size
% --- Executes during object creation, after setting all properties.
function pop_Size_CreateFcn(hObject, eventdata, handles)
% hObject handle to pop_Size (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu8.
function popupmenu8_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu8 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu8
% --- Executes during object creation, after setting all properties.
function popupmenu8_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in pop_PartitionNumber.
function pop_PartitionNumber_Callback(hObject, eventdata, handles)
% hObject handle to pop_PartitionNumber (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns pop_PartitionNumber contents as cell array
% contents{get(hObject,'Value')} returns selected item from pop_PartitionNumber
% --- Executes during object creation, after setting all properties.
function pop_PartitionNumber_CreateFcn(hObject, eventdata, handles)
% hObject handle to pop_PartitionNumber (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_SLMAttempts_Callback(hObject, eventdata, handles)
% hObject handle to txt_SLMAttempts (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_SLMAttempts as text
% str2double(get(hObject,'String')) returns contents of txt_SLMAttempts as a double
% --- Executes during object creation, after setting all properties.
function txt_SLMAttempts_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_SLMAttempts (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_PTSAttempts_Callback(hObject, eventdata, handles)
% hObject handle to txt_PTSAttempts (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_PTSAttempts as text
% str2double(get(hObject,'String')) returns contents of txt_PTSAttempts as a double
% --- Executes during object creation, after setting all properties.
function txt_PTSAttempts_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_PTSAttempts (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_PhaseResolution_Callback(hObject, eventdata, handles)
% hObject handle to txt_PhaseResolution (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_PhaseResolution as text
% str2double(get(hObject,'String')) returns contents of txt_PhaseResolution as a double
% --- Executes during object creation, after setting all properties.
function txt_PhaseResolution_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_PhaseResolution (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in cbx_OFDM.
function cbx_OFDM_Callback(hObject, eventdata, handles)
% hObject handle to cbx_OFDM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of cbx_OFDM
% --- Executes on button press in cbx_SLM.
function cbx_SLM_Callback(hObject, eventdata, handles)
% hObject handle to cbx_SLM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of cbx_SLM
% --- Executes on button press in cbx_PTS.
function cbx_PTS_Callback(hObject, eventdata, handles)
% hObject handle to cbx_PTS (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of cbx_PTS
% --- Executes on selection change in pop_Parameter.
function pop_Parameter_Callback(hObject, eventdata, handles)
% hObject handle to pop_Parameter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns pop_Parameter contents as cell array
% contents{get(hObject,'Value')} returns selected item from pop_Parameter
% --- Executes during object creation, after setting all properties.
function pop_Parameter_CreateFcn(hObject, eventdata, handles)
% hObject handle to pop_Parameter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_Address_Callback(hObject, eventdata, handles)
% hObject handle to txt_Address (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_Address as text
% str2double(get(hObject,'String')) returns contents of txt_Address as a double
% --- Executes during object creation, after setting all properties.
function txt_Address_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_Address (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in btn_Browse.
function btn_Browse_Callback(hObject, eventdata, handles)
% hObject handle to btn_Browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName, PathName] = uigetfile('*.txt', 'Select the parameter list');
set(handles.txt_Address, 'String', [PathName FileName]);
function txt_Log_Callback(hObject, eventdata, handles)
% hObject handle to txt_Log (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_Log as text
% str2double(get(hObject,'String')) returns contents of txt_Log as a double
% --- Executes during object creation, after setting all properties.
function txt_Log_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_Log (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in cbx_SaveGraph.
function cbx_SaveGraph_Callback(hObject, eventdata, handles)
% hObject handle to cbx_SaveGraph (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of cbx_SaveGraph
function GUI_Objects_Enable(Enable, handles)
if Enable
en = 'on';
txt = 'Simulate';
color = 'green';
else
en = 'off';
txt = 'Running';
color = 'red';
end
set(handles.btn_Simulate, 'string', txt, 'enable', en, 'BackgroundColor', color);
set(handles.cbx_OFDM, 'enable', en);
set(handles.cbx_SLM, 'enable', en);
set(handles.cbx_PTS, 'enable', en);
set(handles.pop_QAM, 'enable', en);
set(handles.txt_Carriers, 'enable', en);
set(handles.txt_Length, 'enable', en);
set(handles.pop_Size, 'enable', en);
set(handles.txt_PhaseResolution, 'enable', en);
set(handles.txt_SLMAttempts, 'enable', en);
set(handles.pop_PartitionNumber, 'enable', en);
set(handles.txt_PTSAttempts, 'enable', en);
set(handles.pop_Parameter, 'enable', en);
set(handles.cbx_SaveGraph, 'enable', en);
% --- Executes on button press in btn_Simulate.
function btn_Simulate_Callback(hObject, eventdata, handles)
% hObject handle to btn_Simulate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% GUI Objects
% btn_Simulate : stars simulation
% txt_Log : text box for logs and errors
% cbx_OFDM : run regular OFDM simulation
% cbx_SLM : run OFDM with SLM simulation
% cbx_PTS : run OFDM with PTS simulation
% pop_QAM : QAM modulation
% txt_Carriers : number of carriers
% txt_Length : number of OFDM symbols
% pop_Size : IFFT size
% txt_PhaseResolution : SLM and PTS phase resolution
% txt_SLMAttempts : number of reduction attempts using SLM
% pop_PartitionNumber : number of partitions in PTS
% txt_PTSAttempts : number of reduction attempts using PTS
% pop_Parameter : run a set from .txt file in parameters folder
% cbx_SaveGraph : check if you want to save the output graph
% txt_GraphName : graph name
%% Clear
cla
clc
legend('off')
%% Initialize
% Set GUI
set(handles.txt_Log, 'string', '');
GUI_Objects_Enable(false, handles);
% Get Configurations
pause(1)
Ms = get(handles.pop_QAM, 'string');
Mvalue = get(handles.pop_QAM, 'value');
% QAM constellation order size
Config.M = str2num(cell2mat(Ms(Mvalue)));
% Number of carriers
Config.Carriers_gui = str2num(get(handles.txt_Carriers, 'string'));
Config.Carriers = Config.Carriers_gui;
% Number of OFDM symbols to be simulated
Config.m = str2num(get(handles.txt_Length, 'string'));
Ns = get(handles.pop_Size, 'string');
Nvalue = get(handles.pop_Size, 'value');
% Size of OFDM symbols
Config.N = str2num(Ns(Nvalue, :));
% Number of partitions
Config.PhaseRes = str2num(get(handles.txt_PhaseResolution, 'string'));
% SLM resolution
Config.SLMDeph = str2num(get(handles.txt_SLMAttempts, 'string'));
PartitionNumbers = get(handles.pop_PartitionNumber, 'string');
PartitionNumberValue = get(handles.pop_PartitionNumber, 'value');
% Number of PTS partitions (=< q)
Config.PTSPartitions = str2num(cell2mat(PartitionNumbers(PartitionNumberValue)));
% PTS resolution
Config.PTSDeph = str2num(get(handles.txt_PTSAttempts, 'string'));
% Simulate regular OFDM tranceiver (0 - Not to simulate)
Config.SimulateOFDM = get(handles.cbx_OFDM, 'value');
% Simulate OFDM tranceiver with SLM (0 - Not to simulate)
Config.SimulateSLM = get(handles.cbx_SLM, 'value');
% Simulate OFDM tranceiver with PTS (0 - Not to simulate)
Config.SimulatePTS = str2num(get(handles.txt_PTSAttempts, 'string'));
Parameter = get(handles.pop_Parameter, 'value');
ParameterNames = get(handles.pop_Parameter, 'string');
%% Open Parameter List
if Parameter == 1 % NONE
Values = 0;
else
s = cell2mat(ParameterNames(Parameter));
s(regexp(s,'[ ]'))=[];
ValuesAddress = strcat('Parameters\', s, '.txt');
fileID = fopen(ValuesAddress, 'r');
Values = fscanf(fileID, '%d');
end
%% Check For Errors
[Errors] = CheckForErrors(Config, Parameter, Values);
if size(Errors) > 0
% Set GUI it here are errors
set(handles.txt_Log, 'string', Errors);
GUI_Objects_Enable(true, handles)
return
end
%% Simulation
[TxPAPR, SimulationTime, SER, CCDF, Legend] = Configuration_Simulator(Config, Parameter, Values);
%% Display
% Plot
PAPRDisplay_View(Config, CCDF, Legend);
% Log
if SER.Original ~= 0
Log = strcat('Original Signal SER: ', num2str(SER.Original));
elseif SER.Original ~= 0
Log = strcat('SLM Signal SER: ', num2str(SER.SLM));
elseif SER.Original ~= 0
Log = strcat('PTS Signal SER: ', num2str(SER.PTS));
else
Log = 'Simulation Finished Successfully';
end
set(handles.txt_Log, 'string', Log);
% Save To File
saveFigure = get(handles.cbx_SaveGraph, 'value');
if saveFigure ~= 0
graphName = get(handles.txt_GraphName, 'string');
if graphName == ""
graphName = 'figure';
end
figure
PAPRDisplay_View(Config, CCDF, Legend);
saveas(gcf, graphName, 'jpg')
close
end
% Set GUI
GUI_Objects_Enable(true, handles)
function edit19_Callback(hObject, eventdata, handles)
% hObject handle to txt_Length (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_Length as text
% str2double(get(hObject,'String')) returns contents of txt_Length as a double
% --- Executes during object creation, after setting all properties.
function edit19_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_Length (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_Carriers_Callback(hObject, eventdata, handles)
% hObject handle to txt_Carriers (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_Carriers as text
% str2double(get(hObject,'String')) returns contents of txt_Carriers as a double
% --- Executes during object creation, after setting all properties.
function txt_Carriers_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_Carriers (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_GraphName_Callback(hObject, eventdata, handles)
% hObject handle to txt_GraphName (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of txt_GraphName as text
% str2double(get(hObject,'String')) returns contents of txt_GraphName as a double
% --- Executes during object creation, after setting all properties.
function txt_GraphName_CreateFcn(hObject, eventdata, handles)
% hObject handle to txt_GraphName (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end