-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulate.m
77 lines (63 loc) · 2.07 KB
/
simulate.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
% Simulation of a rudimentary DVB-T system
% based on ETSI EN 300 744 V1.6.1 (2009-01)
% Author: Thomas Lipovec
% Last revision: 22-September-2021
% DVB-T Parameters:
% FFT Size = 8192
% Number of used subcarriers = 6817
% Number of data carriers = 6247
% Number of pilots = 570
% Relative CP length = 1/4
% Constellation = 16-QAM
% 1 OFDM Symbol = 8192 + 8192/4 = 10240 samples
% 1 frame = 68 OFDM symbols = 696320 samples
%% Main simulation loop
% SNR values to evaluate
SNRdB = 0:30;
% allocate vector for BER values and estimation errors
BER = zeros(1,numel(SNRdB));
timeOffsetEstMSE = zeros(1,numel(SNRdB));
frequencyOffsetEstMSE = zeros(1,numel(SNRdB));
channelEstMSE = zeros(1,numel(SNRdB));
% plot estimation errors
plotEstimationErrors = false;
% transmitted data bits in 1 frame
nDataBits = 1699252;
for j = 1:numel(SNRdB)
% repeat until at least 10 errors have been observed
i = 1;
errorCount = 0;
while errorCount < 10
[iErrorCount, ~, timeErr, frequencyErr, channelErr] = simulateFrame(SNRdB(j));
errorCount = errorCount + iErrorCount;
BER(j) = errorCount / (i*nDataBits);
timeOffsetEstMSE(j) = timeOffsetEstMSE(j) + timeErr;
frequencyOffsetEstMSE(j) = frequencyOffsetEstMSE(j) + frequencyErr;
channelEstMSE(j) = channelEstMSE(j) + channelErr;
i=i+1;
if errorCount == 0
break;
end
end
timeOffsetEstMSE(j) = timeOffsetEstMSE(j) / (i-1);
frequencyOffsetEstMSE(j) = frequencyOffsetEstMSE(j) / (i-1);
channelEstMSE(j) = channelEstMSE(j) / (i-1);
end
figure();
semilogy(SNRdB, BER);
xlabel('SNR (dB)')
ylabel('BER')
if plotEstimationErrors
figure()
semilogy(SNRdB, timeOffsetEstMSE);
xlabel('SNR (dB)')
ylabel('Timeoffset Estimation MSE')
figure()
semilogy(SNRdB, frequencyOffsetEstMSE);
xlabel('SNR (dB)')
ylabel('Frequency Estimation MSE')
figure()
semilogy(SNRdB, channelEstMSE);
xlabel('SNR (dB)')
ylabel('Channel Estimation MSE')
end