CCS - Digital Transmission via Carrier Modulation - Probability of Error for QAM in an AWGN Channel
Probability of Error for QAM in an AWGN Channel
Matlab Coding
1 % MATLAB script for Illustrative Problem 7.6. 2 echo on 3 SNRindB1=0:2:15; 4 SNRindB2=0:0.1:15; 5 M=16; 6 k=log2(M); 7 for i=1:length(SNRindB1), 8 smld_err_prb(i)=cm_sm41(SNRindB1(i)); % simulated error rate 9 echo off; 10 end; 11 echo on ; 12 for i=1:length(SNRindB2), 13 SNR=exp(SNRindB2(i)*log(10)/10); % signal-to-noise ratio 14 % theoretical symbol error rate 15 theo_err_prb(i)=4*Qfunct(sqrt(3*k*SNR/(M-1))); 16 echo off ; 17 end; 18 echo on ;
19 % Plotting commands follow. 20 semilogy(SNRindB1,smld_err_prb,'*'); 21 hold 22 semilogy(SNRindB2,theo_err_prb); 23 24 25 function [p]=cm_sm41(snr_in_dB) 26 % [p]=cm_sm41(snr_in_dB) 27 % CM_SM41 finds the probability of error for the given 28 % value of snr_in_dB, SNR in dB. 29 N=10000; 30 d=1; % min. distance between symbols 31 Eav=10*d^2; % energy per symbol 32 snr=10^(snr_in_dB/10); % SNR per bit (given) 33 sgma=sqrt(Eav/(8*snr)); % noise variance 34 M=16;
35 % Generation of the data source follows. 36 for i=1:N, 37 temp=rand; % a uniform R.V. between 0 and 1 38 dsource(i)=1+floor(M*temp); % a number between 1 and 16, uniform 39 end;
40 % Mapping to the signal constellation follows. 41 mapping=[-3*d 3*d; 42 -d 3*d; 43 d 3*d; 44 3*d 3*d; 45 -3*d d; 46 -d d; 47 d d; 48 3*d d; 49 -3*d -d; 50 -d -d; 51 d -d; 52 3*d -d; 53 -3*d -3*d; 54 -d -3*d; 55 d -3*d; 56 3*d -3*d];
57 for i=1:N, 58 qam_sig(i,:)=mapping(dsource(i),:); 59 end;
60 % received signal 61 for i=1:N, 62 [n(1) n(2)]=gngauss(sgma); 63 r(i,:)=qam_sig(i,:)+n; 64 end;
65 % detection and error probability calculation 66 numoferr=0; 67 for i=1:N, 68 % Metric computation follows. 69 for j=1:M, 70 metrics(j)=(r(i,1)-mapping(j,1))^2+(r(i,2)-mapping(j,2))^2; 71 end; 72 [min_metric decis] = min(metrics); 73 if (decis~=dsource(i)), 74 numoferr=numoferr+1; 75 end; 76 end; 77 p=numoferr/(N);
Simulation Result
Reference,
1. <<Contemporary Communication System using MATLAB>> - John G. Proakis