Why does the theoretical BER not coincide with the simulation one?

12 Ansichten (letzte 30 Tage)
Vtoroy
Vtoroy am 21 Dez. 2023
Beantwortet: Rangesh am 26 Dez. 2023
clc;
clear all;
close all;
M = 4; % Modulation order
K = log2(M); % Bits per symbol
EbNoVec = (-10:1:10); % Eb/No values (dB)
numSymPerFrame = 100; % Number of PSK symbols per frame
N=10^6;
berEst = zeros(size(EbNoVec));
for i = 1:length(EbNoVec)
snrdB = EbNoVec(i) + 10*log10(K);
% Reset the error and bit counters
numErrs = 0;
numBits = 0;
while numErrs < 200 && numBits < 1e6
% Generate binary data and convert to symbols
dataIn = randi([0 1],N,1);
n = 7; % Kolichestvo vsekh bitov na simvol.
k = 4;
txEncoded = encode(dataIn,n,k, 'hamming');%%%%%%%%%%%%%%
dataSym = bit2int(txEncoded,K);
% QAM modulate using 'Gray' symbol mapping
txSig = pskmod(dataSym,M);
% Pass through AWGN channel
rxSig = awgn(txSig,snrdB,'measured');
% Demodulate the noisy signal
rxSym = pskdemod(rxSig,M);
% Convert received symbols to bits
dataOut = int2bit(rxSym,K);
rxDecoded = decode(dataOut,n,k,'hamming');
% Calculate the number of bit errors
nErrors = biterr(dataIn,rxDecoded);
% Increment the error and bit counters
numErrs = numErrs + nErrors;
numBits = numBits + N;
end
% Estimate the BER
berEst(i) = numErrs/numBits;
end
berTheory = berawgn(EbNoVec,'psk',M, 'nondiff');
semilogy(EbNoVec,berEst,'*')
hold on
semilogy(EbNoVec,berTheory)
grid
legend('Estimated BER','Theoretical BER')
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')

Antworten (1)

Rangesh
Rangesh am 26 Dez. 2023
Hi Vtoroy,
I understand that you are seeking to identify why the theoretical value of BER does not align with the simulation results.
It's important to note that the use of a hamming code aims to reduce the BER by correcting the error. However, the function "berawgn" used for the theoretical value calculation does not account for the application of the hamming code. Consequently, there is a decrease in the BER rate compared to the theoretical values. That’s why there is a discrepancy in the simulation and the theoretical results.
To observe how the results compare, you can eliminate the encoding performed through the hamming code. Here is the modified code without the hamming code encoding:
M = 4; % Modulation order
K = log2(M); % Bits per symbol
EbNoVec = (-10:1:10); % Eb/No values (dB)
numSymPerFrame = 100; % Number of PSK symbols per frame
N=10^6;
berEst = zeros(size(EbNoVec));
for i = 1:length(EbNoVec)
snrdB = EbNoVec(i) + 10*log10(K);
% Reset the error and bit counter
numErrs = 0;
numBits = 0;
while numErrs < 200 && numBits < 1e6
% Generate binary data and convert to symbols
dataIn = randi([0 1],N,1);
n = 7; % Kolichestvo vsekh bitov na simvol.
k = 4;
% txEncoded = encode(dataIn,n,k, 'hamming');%%%%%%%%%%%%%%
dataSym = bit2int(dataIn,K);
% QAM modulate using 'Gray' symbol mapping
txSig = pskmod(dataSym,M);
% Pass through AWGN channel
rxSig = awgn(txSig,snrdB,'measured');
% Demodulate the noisy signal
rxSym = pskdemod(rxSig,M);
% Convert received symbols to bits
dataOut = int2bit(rxSym,K);
% rxDecoded = decode(dataOut,n,k,'hamming');
% Calculate the number of bit errors
nErrors = biterr(dataIn,dataOut);
% Increment the error and bit counters
numErrs = numErrs + nErrors;
numBits = numBits + N;
end
% Estimate the BER
berEst(i) = numErrs/numBits;
end
berTheory = berawgn(EbNoVec,'psk',M, 'nondiff');
semilogy(EbNoVec,berEst,'*')
hold on
semilogy(EbNoVec,berTheory)
grid
legend('Estimated BER','Theoretical BER')
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')
For further understanding, you can refer the following documentation:
I hope this resolves your query.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by