File Exchange

## 16QAM BER with Gray Mapping

version 1.0.0.0 (1.55 KB) by
Derive the theoretical 16QAM bit error rate (BER) with Gray coded constellation mapping in AWGN

Updated 07 Jul 2008

The Matlab/Octave script performs the following:
(a) Generation of random binary sequence
(b) Assigning group of 4 bits to each 16-QAM constellation symbol per the Gray mapping
(c) Addition of white Gaussian Noise
(d) Demodulation of 16-QAM symbols and
(e) De-mapping per decimal to Gray conversion
(f) Counting the number of bit errors
(g) Running this for each value of Eb/No in steps of 1dB.
For the discussion on the theoretical BER for 16QAM, please refer to the post
http://www.dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

### Cite As

Krishna Sankar M (2021). 16QAM BER with Gray Mapping (https://www.mathworks.com/matlabcentral/fileexchange/20569-16qam-ber-with-gray-mapping), MATLAB Central File Exchange. Retrieved .

Safia BOUCHAFA

Dear @Krishna Pillai,
I really need your help on matlab code of Demapping 16QAM, in fact I implemented the code but the BER is very high. I would be grathful if you can help me. Thanks in advance
if nb_bit_per_symb == 4
for i=1:1:nb_symb
if real(symb_RX_estimated(i)) ==-3
bit_RX(4*i-3)= 0;
bit_RX(4*i-2)= 0;

elseif real(symb_RX_estimated(i)) ==-1
bit_RX(4*i-3)= 0;
bit_RX(4*i-2)= 1;

elseif real(symb_RX_estimated(i)) ==1
bit_RX(4*i-3)= 1;
bit_RX(4*i-2)= 1;

else
bit_RX(4*i-3)= 1;
bit_RX(4*i-2)= 0;
end
if imag(symb_RX_estimated(i)) ==3
bit_RX(4*i-1)= 0;
bit_RX(4*i)= 0;

elseif imag(symb_RX_estimated(i)) ==1
bit_RX(4*i-1)= 0;
bit_RX(4*i)= 1;

elseif imag(symb_RX_estimated(i)) ==-1
bit_RX(4*i-1)= 1;
bit_RX(4*i)= 1;
else
bit_RX(4*i-1)= 1;
bit_RX(4*i)= 0;
end
end
% Code here the demapping function for 16QAM constellation with Gray
% coding (output: bit_RX)

end

Krishna Pillai

@Paul: Thanks for the comment. Sure, I can add link to your code (with credits) in www.dsplog.com.

However, I would like to understand the equation prior. For a general M-QAM (M-even), the symbol error rate has an erfc() term and erfc^2() term.
uri: http://www.dsplog.com/2008/05/24/article-in-dspdesignlinecom-m-qam-symbol-error/
And for ber, I just took the first term. Given the above understanding, I was unable to understand the equation which you have suggested. How have you converted the erfc^2() term to two erfc() terms? Kindly point me to a reference, if possible.

Warm regards,
Krishna

Paul A.M. Buné

Excellent tutorial. However, please be aware that the theoretical 16QAM BER as used in this program
BER=(3/8)*erfc(sqrt(0.4*Eb_N0))
is just an (albeit good) approximation, as you already indicated in your www.dsplog.com post.

The *exact* Gray-mapped 16QAM BER with AWGN is
BER=(3/8)*erfc(sqrt(0.4*Eb_N0))+(1/4)*erfc(3*sqrt(0.4*Eb_N0))-(1/8)*erfc(5*sqrt(0.4*Eb_N0))
as generated by entry nr. 19717 in the Mathworks File Exchange. The difference between the approximate theoretical BER and the exact BER gets significant for Eb/N0 below 0dB, being 27% at Eb/N0=-10dB and growing to 33% for Eb/N0=0 (or minus infinity in dB). The simulated 16QAM BER can be shown to deviate clearly from the approximate theoretical BER for Eb/N0<0dB, while it closely follows the exact theoretical BER for all values of Eb/N0.

Entry 19717 also produces exact BER values for Gray-mapped QPSK, 256QAM etc. and, further to over-all BER values, it also generates the different BER values for the different bit positions in 16QAM, 256QAM etc.

On the condition that the origin is clearly indicated, please feel free to use my entry nr. 19717 and its results on your site http://www.dsplog.com/.

Paul A.M. Buné

##### MATLAB Release Compatibility
Created with R14
Compatible with any release
##### Platform Compatibility
Windows macOS Linux