Почему теоретическая BER не совпадает с имитационной?
Добрый вечер. Помогите разобраться в чем тут ошибка. Нужно, чтобы оба графика совпадали.
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')
Комментарии