Documente Academic
Documente Profesional
Documente Cultură
CHICAGO
A D VA N C E D D I G I TA L
C O M M U N I C AT I O N
Assignment 5:
16-QAM Digital
Modulation
G O W T H A M S I VA K U M A R
UIN: 674422979
Question:
1. Generate a random sequence of bits denoted by
databits. Let its length be Nbits.
2. Map the sequence databit into a sequence of
16QAM symbols called tx_symsusing Gray mapping.
Plot the sequence tx_syms onto the complex plane.
3. The receiver symbols rx_syms are equal to the
transmitted symbols tx_syms plus white noise such
that the signal-to-noise ratio in dB is SNRdB. Let SNRdB
vary between 0 and 15 dB.
4. Demodulate the received symbols rx_syms and
denote the demodulated symbols est_syms.
5. Determine the error sequence syms_error and find
the number of positions in which syms and est_syms
differ, i.e. the symbol error rate.
6. Convert the symbols est_syms to a sequence of bits
est_bits.
7. Determine the error sequence bits_error and find
the number of positions in which databits and
est_bits differ, i.e. the bit error rate.
8. Plot the symbol error rate and the bit error rate
versus the SNR.
9. Change the modulation mapping so that it is not a
Gray mapping.
10. With the new mapping, calculate and plot the
symbol error rate and the bit error rate again.
Write a short report commenting all results and
include all plots. Submit your .m file in addition to
your report.
Code:
clearall;
clc;
Nbits=input('Inputdatabitlengthofeachuser=');%inputbits
M=16;%Sizeofsignalconstellation
k=log2(M);%Numberofbitspersymbol
databit=round(randi([0,1],Nbits,1));%randombinarysequenceofNbits
datainmat=reshape(databit,length(databit)/4,4);%reshapingdatainto4
tuples
data_in=bi2de(datainmat);%intconversion
tx_syms=qammod(data_in,16,0,'bin');%BinaryQAMcoding
tx_symsG=qammod(data_in,16,0,'gray');%GrayQAMcoding
scatterplot(tx_syms)
text(real(tx_syms)+0.1,imag(tx_syms),dec2bin(data_in))
title('16QAM,BincodedSymbolMapping')
axis([4444])
title('BinaryCoded16QAMConstellation')%PlottingSignal
constellationsforbinary
scatterplot(tx_symsG)
text(real(tx_symsG)+0.1,imag(tx_symsG),dec2bin(data_in))
title('16QAM,GraycodedSymbolMapping')
axis([4444])
title('GrayCoded16QAMConstellation')%PlottingSignalconstellations
forgray
figure,
%Graycoding
forEbN0=0:1:15%generallyEbNovaluewillbegivenbutletsassumeit
asSNR
SNRdBG=EbN0;
rx_symsG=awgn(tx_symsG,SNRdBG,'measured');%addingNoise(AWGN)
est_symsG=qamdemod(rx_symsG,16,0,'gray');%DemodulatingtheNoisy
Signal
[nosymerrG,SERG]=symerr(data_in,est_symsG);%symerrfunctionto
determinethenumberoferrorsandtheassociatedSER
datasymmatrixG=de2bi(est_symsG,4);%viterbidecoding
est_bitsG=datasymmatrixG(:);%returndataascolumnmatrix
[biterrG,BERG]=biterr(databit,est_bitsG);%biterrfunctionto
determinethenumberoferrorsandtheassociatedBER.
holdon
subplot(2,1,1);
semilogy(SNRdBG,BERG,'b*');
semilogy(SNRdBG,SERG,'go');%PlottingBER/SERVs.SNR
end
title('BER&SERVs.SNRGrayCoded16QAM')
xlabel('SNR(dB)')
ylabel('BER/SER')
legend('BER','SER')
%Binarycoding
forEbno=0:1:15%ideallyEbNovaluewillbegivenbutletsassumeitas
SNR
SNRdB=Ebno;
rx_syms=awgn(tx_syms,SNRdB,'measured');%addingNoise(AWGN)
est_syms=qamdemod(rx_syms,16,0,'bin');%DemodulatingtheNoisySignal
[nosymerr,SER]=symerr(data_in,est_syms);%symerrfunctionto
determinethenumberoferrorsandtheassociatedSER
datasymbolmatrix=de2bi(est_syms,4);%viterbidecoding
est_bits=datasymbolmatrix(:);%returndataascolumnmatrix
[numbiterr,BER]=biterr(databit,est_bits);%biterrfunctionto
determinethenumberoferrorsandtheassociatedBER.
holdon
subplot(2,1,2);
semilogy(SNRdB,BER,'*');
semilogy(SNRdB,SER,'ro');%PlottingBER/SERVs.SNR
end
title('BER&SERVs.SNRBinaryCoded16QAM')
xlabel('SNR(dB)')
ylabel('BER/SER')
legend('BER','SER')
Output:
Figure2: tx_syms
onto the complex
plane
Figure3: tx_symsG
onto the complex
plane
Notes:
The decoding operation incurs a delay, which means that the output of the
decoder lags the input. Timing informationcould be added by adding a timer, and
the duration of the delay depends on the specific operations being performed.
Delays occur in various communications-related operations, including
convolutional decoding, convolutional interleaving/deinterleaving, equalization,
and filtering. (Source: Matlab Central)
The values of BER and SER in Gray coding is typically less than that of Binary
coding and hence more efficient.
I have provided as much details possible in the comment section for reference.
For the sake of simplicity, I have provided the code for Binary and Gray coding in
the same page.
Reference:
http://www.mathworks.com/help/comm/gs/computeberfora
qamsystemwithawgnusingmatlab.html