Demonstration of EB/N0 VS SER For 16-QAM Modulation Scheme-Rayleigh

MATLAB PROGRAM

clear; clc;

%---------Input Fields------------------------

N=100000; %Number of input symbols

EbN0dB = 0:1:30; %Define EbN0dB range for simulation

M=16; %for 16-QAM modulation.

%---------------------------------------------

refArray =1/sqrt(8)*[-3-3j,-3-1j,-3+3j,-3+1j,-1-3j,-1-1j,-1+3j,-1+1j,3-3j,3-1j,3+3j,3+1j,1-3j,1-1j,1+3j,1+1j];

symErrSimulated = zeros(1,length(EbN0dB));

k=log2(M);

EsN0dB = EbN0dB + 10*log10(k);

%---Generating a uniformly distributed random numbers in the set [0,1,2,..,M-1]

data=ceil(M.*rand(N,1))-1;

s=refArray(data+1); %16-QAM Constellation mapping with Gray coding

%--- Reference Constellation for demodulation and Error rate computation--

refI = real(refArray);

refQ = imag(refArray);

%---Place holder for Symbol Error values for each Es/N0 for particular M value--

index=1;

for x=EsN0dB,

  %-------------------------------------------

  %Channel Noise for various Es/N0

  %-------------------------------------------

  %Adding noise with variance according to the required Es/N0

  noiseVariance = 1/(10.^(x/10));%Standard deviation for AWGN Noise

  noiseSigma = sqrt(noiseVariance/log2(M));

  %Creating a complex noise for adding with M-QAM modulated signal

  %Noise is complex since M-QAM is in complex representation

  noise = noiseSigma*(randn(size(s))+1i*randn(size(s)));

  %Rayleigh Flat Fading factor- single tap

  h=1/sqrt(2)*(randn(1,length(s))+1i*randn(1,length(s)));

  received = h.*s + noise;

  %-------------------------------------------

  %Coherent Receiver for Rayleigh Channel

  received_cap=received./h; %Assuming that h is known at the signal accurately

  %-------------I-Q Branching---------------

  r_i = real(received_cap);

  r_q = imag(received_cap);

  %---Decision Maker-Compute (r_i-s_i)^2+(r_q-s_q)^2 and choose the smallest

  r_i_repmat = repmat(r_i,M,1);

  r_q_repmat = repmat(r_q,M,1);

  distance = zeros(M,N); %place holder for distance metric

  minDistIndex=zeros(N,1);

  for j=1:N

%---Distance computation - (r_i-s_i)^2+(r_q-s_q)^2 --------------

    distance(:,j) = (r_i_repmat(:,j)-refI').^2+(r_q_repmat(:,j)-refQ').^2;

%---capture the index in the array where the minimum distance occurs

    [dummy,minDistIndex(j)]=min(distance(:,j));

  end

  y = minDistIndex - 1;%The index becomes the decoded symbol

  %--------------Symbol Error Rate Calculation-------------------------------

  dataCap = y;

  symErrSimulated(1,index) = sum(dataCap~=data)/N;

  index=index+1;

end

%----- Compute Theoretical Symbol Error Rates ---------------------

EbN0lin = 10.^(EbN0dB/10);

if(M==4)

a=1;

else

  a=4/log2(M);

end

b=3*log2(M)/(M-1);

symErrTheory=[];

for i = 1:31,

  symErrTheory= [symErrTheory 0.5*a*(1-sqrt(0.5*b*EbN0lin(i)/(1+0.5*b*EbN0lin(i))))];

end 

%---------------Plotting commands-----------------------

figure;

semilogy(EbN0dB,symErrTheory,'r-');

hold on;

semilogy(EbN0dB,symErrSimulated,'b*');

legend('16QAM-Theory','16QAM-Sim');

xlabel('Eb/N0(dB)');

ylabel('Symbol Error Rate (Ps)');

grid on;


SIMULATED OUTPUT

DOWNLOAD LINK