# How to plotthe estimated probability of a bit error for FSK

25 views (last 30 days)
Mahabba Almheiri on 9 May 2021
Answered: Arthi Sathyamurthi on 27 May 2021
I implemented the following code to comapare between estimated and theoretical probability of bit error and everything is correct except the part of estimated probability of a bit error it didn't work. Can you help me to modify the following code :
M=4 %Moulation order
set = [0 0; 0 1; 1 0; 1 1]; %transmitted possibilities
%generate a 10000-by-2 column vector of uniformly distributed random integers from the sample interval [0,1].
B = randi([0 1], 10000,2);
%List of symbols
S = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1];
%Convert the binary vector S to decimal value D
D = bi2de(B,'left-msb');
%The binary sequence is grouped into pairs of bits, which are mapped into the corresponding signal components
X = S(D+1,:);
%SNR in dB
snrdB = 0:8;
% Eb/No
EbNodB = snrdB-10*log10(2);
%Creating a loop
for i = 1:length(snrdB)
Y = awgn(X,snrdB(i),'measured');%Adding White Gaussian noise to x
corr=Y*S';%correlataion between Y and trasnpose S
[val,indx] = max(corr,[],2); %Finding the maximum correlation
[nBe(i),p(i)]=biterr(B,R); %bit error rate
end
berEst(i)= biterr(B,R)./20000;
berTheory = berawgn(EbNodB,'fsk',M,'coherent')
semilogy(EbNodB,berEst,'*')
hold on
semilogy(EbNodB,berTheory,'r');
grid on;
legend('Estimated BER','Theoretical BER')
title('Theoretical Bit Error Rate');
xlabel('Eb/No (dB)');
ylabel('Bit Error Rate');
grid on;

Arthi Sathyamurthi on 27 May 2021
Hi Mahabba,
The berawgn takes Eb/N0 value as bit energy to noise power spectral density ratio (in dB). This requires calculating and plot the BER by using snrdB variable in your program. Also, the estimation of BER and its supporting calculations can be done at one place and need not be done inside the loop to improve the speed.
Pl. find the snippet of the modified program.
M=4; % Modulation order
set = [0 0; 0 1; 1 0; 1 1]; % Transmitted possibilities
% Generate a 10000-by-2 column vector of uniformly distributed random integers from the sample interval [0,1].
B = randi([0 1], 10000,2);
% List of symbols
S = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1];
% Convert the binary vector S to decimal value D
D = bi2de(B,'left-msb');
% The binary sequence is grouped into pairs of bits, which are mapped into the corresponding signal components
X = S(D+1,:);
%SNR in dB
snrdB = 0:8;
%Creating a loop
for i = 1:length(snrdB)
Y = awgn(X,snrdB(i),'measured');% Adding White Gaussian noise to x
end
corr=Y*S'; % Correlataion between Y and trasnpose S
[val,indx] = max(corr,[],2); % Finding the maximum correlation
R = set(indx,:); % Received signal
berEst(i)= biterr(B,R)./20000;
berTheory = berawgn(snrdB,'fsk',M,'coherent')
semilogy(snrdB,berEst,'*')
hold on
semilogy(snrdB,berTheory,'r');
grid on;
legend('Estimated BER','Theoretical BER')
title('Theoretical Bit Error Rate');
xlabel('Eb/No (dB)');
ylabel('Bit Error Rate');
grid on;