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
| M = 16; % M determine the size of signal constellation
k = log2(M); % k determine the number of bits per symbol
n = 3e4; % n determine the number of bits to process
nSyms = n/k; % nSyms represent the number of symbols
hMod = modem.qammod(M); % We will create a 16-QAM modulator
hMod.InputType = 'Bit'; % Then accept bits as inputs
hMod.SymbolOrder = 'Gray'; % accept bits as inputs
hDemod = modem.qamdemod(hMod); %
x = randi([0 1],n,1); % Random binary data stream
tx = modulate(hMod,x);
EbNo = 0:10; % In dB
SNR = EbNo + 10*log10(k);
rx = zeros(nSyms,length(SNR));
bit_error_rate = zeros(length(SNR),1);
for i=1:length(SNR)
rx(:,i) = awgn(tx,SNR(i),'measured');
end
rx_demod = demodulate(hDemod,rx);
for i=1:length(SNR)
[~,bit_error_rate(i)] = biterr(x,rx_demod(:,i));
end
theoryBer = 3/(2*k)*erfc(sqrt(0.1*k*(10.^(EbNo/10))));
figure;
semilogy(EbNo,theoryBer,'-',EbNo, bit_error_rate, '^-');
grid on;
legend('Theory BER', 'simulation');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for 16-QAM modulation'); |
Partager