-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathldpc_time_BER.m
More file actions
80 lines (64 loc) · 2.7 KB
/
Copy pathldpc_time_BER.m
File metadata and controls
80 lines (64 loc) · 2.7 KB
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
% Function to generate demodulator bar graph with LLR Mean relative erro
function ldpc_time_BER(noise, iter, path)
% Load colors from colors.m
run("colors.m");
% Number of different modulations
M = 5;
% Import data from log_data.txt file
logdata = readtable(path + '/log_data.txt');
% Check if 3 different LDPC iterations were given
if length(iter) ~= 3
disp("3 different LDPC Iterations are required. Exiting...");
return;
end
% Extract data from table for specific noise and LDPC iterations
idx1 = find(logdata.EbN0dB == noise & logdata.LDPC_Iter == iter(1));
idx2 = find(logdata.EbN0dB == noise & logdata.LDPC_Iter == iter(2));
idx3 = find(logdata.EbN0dB == noise & logdata.LDPC_Iter == iter(3));
% Create array with time values for each iteration
y(1:M,1) = logdata.Decoder(idx1);
y(1:M,2) = logdata.Decoder(idx2);
y(1:M,3) = logdata.Decoder(idx3);
% Create array with BER values for each LDPC iteration
ber(1:M,1) = logdata.BER(idx1);
ber(1:M,2) = logdata.BER(idx2);
ber(1:M,3) = logdata.BER(idx3);
% Create array with xaxis labels
x_labels(idx1) = "QAM" + logdata.Modulation(idx1);
x_labels = rmmissing(x_labels);
figure;
% Create axes
colororder([0 0 0]);
% yyaxis right;
b = bar(y);
b(1).FaceColor = navy_blue;
b(2).FaceColor = steel_blue;
b(3).FaceColor = powder_blue;
ylabel("Execution time [ms]");
% ylim([0 2500]);
% yyaxis left;
yyaxis right;
x_ber = 1:1:M;
semilogy(x_ber, ber(:,1) + 0.0001, "-^", "MarkerSize", 7, "MarkerFaceColor", dark_red, "Color", dark_red);
hold on;
semilogy(x_ber, ber(:,2) + 0.0001, ":^", "MarkerSize", 7, "MarkerFaceColor", dark_red, "Color", dark_red);
semilogy(x_ber, ber(:,3) + 0.0001, "-.^", "MarkerSize", 7, "MarkerFaceColor", dark_red, "Color", dark_red);
hold off;
axis padded;
ylabel("Bit Error Rate (BER)");
% Add x axis labels
xticklabels(x_labels);
% Misc plot settings
title("LDPC Decoder Iterations (Eb/N0=" + noise + "dB, 8 Blocks)");
grid on;
xlabel("Modulation type");
legend("BER (" + iter(1) + " Iterations)", "BER (" + iter(2) + " Iterations)", "BER (" + iter(3) + " Iterations)", ...
"LDPC " + iter(1) + " Iterations", "LDPC " + iter(2) + " Iterations", "LDPC " + iter(3) + " Iterations",...
"Location", "southoutside", "NumColumns", 2, "FontSize", 8);
% "Location", "northwest");
set(gca, "SortMethod", "Depth");
set(gcf, "renderer", "Painters");
% saveas(gcf, "plots/ldpc_plot_" + path + "_EbN0dB_" + noise, "epsc");
saveas(gcf, "plots/ldpc_plot_EbN0dB_" + noise, "epsc");
save("data");
end