Comparing Theoretical and Empirical Error Rates

The example below uses the berawgn function to compute symbol error rates for pulse amplitude modulation (PAM) with a series of Eb/N0 values. For comparison, the code simulates 8–PAM with an AWGN channel and computes empirical symbol error rates. The code also plots the theoretical and empirical symbol error rates on the same set of axes.

% 1. Compute theoretical error rate using BERAWGN.
M = 8; EbNo = [0:13];
ser = berawgn(EbNo,'pam',M).*log2(M);
% Plot theoretical results.
figure; semilogy(EbNo,ser,'r');
xlabel('E_b/N_0 (dB)'); ylabel('Symbol Error Rate');
grid on; drawnow;

% 2. Compute empirical error rate by simulating.
% Set up.
n = 10000; % Number of symbols to process
k = log2(M); % Number of bits per symbol
% Convert from EbNo to SNR.
% Note: Because No = 2*noiseVariance^2, we must add 3 dB
% to get SNR. For details, see Proakis book listed in
% "Selected Bibliography for Performance Evaluation."
snr = EbNo+3+10*log10(k);
ynoisy=zeros(n,length(snr)); % Preallocate to save time.

% Main steps in the simulation
x = randint(n,1,M); % Create message signal.
y = pammod(x,M); % Modulate.
% Send modulated signal through AWGN channel.
% Loop over different SNR values.
for jj = 1:length(snr)
   ynoisy(:,jj) = awgn(real(y),snr(jj),'measured');
end
z = pamdemod(ynoisy,M); % Demodulate.

% Compute symbol error rate from simulation.
[num,rt] = symerr(x,z);

% 3. Plot empirical results, in same figure.
hold on; semilogy(EbNo,rt,'b.');
legend('Theoretical SER','Empirical SER');
title('Comparing Theoretical and Empirical Error Rates');
hold off;

The example produces a plot like the one below. Your plot might vary because the simulation uses random numbers.


© 1994-2005 The MathWorks, Inc.