-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBitErrorRate.m
42 lines (34 loc) · 1.01 KB
/
BitErrorRate.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
clc
clear
Nt = 3;Nr=[2,3];b = 2;
SNR = [0:3:21];
for j= 1:length(Nr)
berSM(j,:) = SM(Nt,Nr(j),SNR)
end
for i = 1:length(Nr)
for n = 1:length(SNR)
numErrs = 0;
numBits = 0;
while numErrs < 200 && numBits < 5e5
len = floor(log2(factorial(Nt))) + Nt*b;
dataIn = randi([0 1],1,100*len);
dataOut = DSM(dataIn,Nt,Nr(i),b,SNR(n));
% Calculate the number of bit errors
nErrors = biterr(dataIn(len+1:100*len),dataOut(len+1:100*len));
% Increment the error and bit counters
numErrs = numErrs + nErrors;
numBits = numBits + length(dataIn);
end
% Estimate the BER
berDSM(i,n) = numErrs/numBits
end
end
%figure;
semilogy(SNR,berSM,'-o');
hold on;
grid on;
semilogy(SNR,berDSM,'-s');
xlabel('SNR in dB');
legend({'SM Nt=3 Nr=2 BPSK','SM Nt=3 Nr=3 BPSK','DSM Nt=3 Nr=2 QPSK', 'DSM Nt=3 Nr=3 QPSK'})
ylabel('Bit Error Rate');
title('DSM vs SM');