-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_BER_PER_over_MCS_plot_PDC.m
232 lines (200 loc) · 8.5 KB
/
main_BER_PER_over_MCS_plot_PDC.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
clear all;
close all;
% This scripts plots the results generated with main_BER_PER_over_MCS.m.
load('results/var_all.mat');
ber_global = n_bits_PDC_error_global./n_bits_PDC_sent_global;
per_global = n_packets_PDC_error_global./n_packets_PDC_sent_global;
% required plot configuration
K = db2pow(9.0);
set(groot,'defaultAxesTickLabelInterpreter','latex');
set(groot,'defaultLegendInterpreter','latex');
set(groot,'defaultTextInterpreter','latex');
% plot configuration
colors = [0, 0.4470, 0.7410;...
0.8500, 0.3250, 0.0980;...
0.9290, 0.6940, 0.1250;...
0.4940, 0.1840, 0.5560;...
0.4660, 0.6740, 0.1880;...
0.3010, 0.7450, 0.9330;...
0.6350, 0.0780, 0.1840;...
0.6350, 0.0780, 0.1840;...
0.6350, 0.0780, 0.1840;...
0.6350, 0.0780, 0.1840;...
0.6350, 0.0780, 0.1840;...
0.6350, 0.0780, 0.1840;...
0.6350, 0.0780, 0.1840;...
0.6350, 0.0780, 0.1840];
legend_font_size = 8;
marker_size = 4;
axis_lim = [-15 55 1e-7 1e1];
legend_location = 'NorthEast';
figure()
clf()
for cnt = 1:1:numel(mcs_index_vec)
% bits per symbol
bps = bps_global(cnt);
M = 2^bps;
% convert subcarrier snr to ebn0
%
% S/N = R_b * E_b / (B * N0)
%
% R_b = bps / T
% B = 1 / T
%
% S/N = bps * E_b/N0
%
% source: https://www.gaussianwaves.com/2008/11/relation-between-ebn0-and-snr-2/
EbN0_vec = db2pow(snr_db_vec_global(cnt,:))/bps;
EbN0_dB_vec = pow2db(EbN0_vec);
% AWGN, diversity order 1
if M==2
ber_rayleigh = berawgn(EbN0_dB_vec,'psk',M,'nondiff');
else
ber_rayleigh = berawgn(EbN0_dB_vec,'qam',M);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', AWGN');
semilogy(snr_db_vec_global(cnt,:), ber_rayleigh,'-','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RAYLEIGH, diversity order 1
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,1);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,1);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rayleigh');
semilogy(snr_db_vec_global(cnt,:), ber_rayleigh,'--','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RAYLEIGH, diversity order 2
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,2);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,2);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rayleigh div=2');
semilogy(snr_db_vec_global(cnt,:), ber_rayleigh,'-.','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RICIAN, diversity order 1
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,1,K);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,1,K);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rician');
semilogy(snr_db_vec_global(cnt,:), ber_rayleigh,'-o','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RICIAN, diversity order 1
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,2,K);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,2,K);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rician div=2');
semilogy(snr_db_vec_global(cnt,:), ber_rayleigh,'-d','DisplayName',str, 'Color', colors(cnt,:));
hold on
% SIMULATION
% our measured ber
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)));
lineH = semilogy(snr_db_vec_global(cnt,:), ber_global(cnt,:), '-.o','DisplayName',str, 'Color', colors(cnt,:), 'MarkerSize', marker_size, 'MarkerFaceColor', colors(cnt,:));
hold on
% general settings
title('BER uncoded')
xlabel('SNR (dB)')
ylabel('BER uncoded')
legend('Location',legend_location, 'FontSize', legend_font_size)
grid on
axis(axis_lim)
set(gca, 'ColorOrder', jet(100))
end
savefig('results/D_BER_SNR_PDC.fig')
figure()
clf()
for cnt = 1:1:numel(mcs_index_vec)
% bits per symbol
bps = bps_global(cnt);
M = 2^bps;
% convert subcarrier snr to ebn0
%
% S/N = R_b * E_b / (B * N0)
%
% R_b = bps / T
% B = 1 / T
%
% S/N = bps * E_b/N0
%
% source: https://www.gaussianwaves.com/2008/11/relation-between-ebn0-and-snr-2/
EbN0_vec = db2pow(snr_db_vec_global(cnt,:))/bps;
EbN0_dB_vec = pow2db(EbN0_vec);
% AWGN, diversity order 1
if M==2
ber_rayleigh = berawgn(EbN0_dB_vec,'psk',M,'nondiff');
else
ber_rayleigh = berawgn(EbN0_dB_vec,'qam',M);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', AWGN');
semilogy(EbN0_dB_vec, ber_rayleigh,'-','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RAYLEIGH, diversity order 1
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,1);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,1);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rayleigh');
semilogy(EbN0_dB_vec, ber_rayleigh,'--','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RAYLEIGH, diversity order 2
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,2);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,2);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rayleigh div=2');
semilogy(EbN0_dB_vec, ber_rayleigh,'-.','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RICIAN, diversity order 1
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,1,K);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,1,K);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rician');
semilogy(EbN0_dB_vec, ber_rayleigh,'-o','DisplayName',str, 'Color', colors(cnt,:));
hold on
% RICIAN, diversity order 1
if M==2
ber_rayleigh = berfading(EbN0_dB_vec,'psk',M,2,K);
else
ber_rayleigh = berfading(EbN0_dB_vec,'qam',M,2,K);
end
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)), ', rician div=2');
semilogy(EbN0_dB_vec, ber_rayleigh,'-d','DisplayName',str, 'Color', colors(cnt,:));
hold on
% SIMULATION
% our measured ber
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)));
lineH = semilogy(EbN0_dB_vec, ber_global(cnt,:), '-.o','DisplayName',str, 'Color', colors(cnt,:), 'MarkerSize', marker_size, 'MarkerFaceColor', colors(cnt,:));
hold on
% general settings
title('BER uncoded')
xlabel('EbN0 (dB)')
ylabel('BER uncoded')
legend('Location',legend_location, 'FontSize', legend_font_size)
grid on
axis(axis_lim)
set(gca, 'ColorOrder', jet(100))
end
savefig('results/E_BER_EBN0_PDC.fig')
figure()
clf()
for cnt = 1:1:numel(mcs_index_vec)
str = append('MCS=',num2str(mcs_index_vec(cnt)),', TBS=',num2str(tbs_global(cnt)));
semilogy(snr_db_vec_global(cnt,:), per_global(cnt,:),'-o','DisplayName',str, 'Color', colors(cnt,:), 'MarkerSize', marker_size, 'MarkerFaceColor', colors(cnt,:));
hold on
title('Packet Decoding Performance')
xlabel('SNR (dB)')
ylabel('PER')
legend('Location',legend_location, 'FontSize', legend_font_size)
grid on
axis(axis_lim)
end
savefig('results/F_PER_SNR_PDC.fig')