Products & Services Solutions Academia Support User Community Company

Learn more about Communications Toolbox   

Error Rate Plots

Section Overview

Error rate plots provide a visual way to examine the performance of a communication system, and they are often included in publications. This section mentions some of the tools you can use to create error rate plots, modify them to suit your needs, and do curve fitting on error rate data. It also provides an example of curve fitting. For more detailed discussions about the more general plotting capabilities in MATLAB, see the MATLAB documentation set.

Creating Error Rate Plots Using semilogy

In many error rate plots, the horizontal axis indicates Eb/N0 values in dB and the vertical axis indicates the error rate using a logarithmic (base 10) scale. To see an example of such a plot, as well as the code that creates it, see Comparing Theoretical and Empirical Error Rates. The part of that example that creates the plot uses the semilogy function to produce a logarithmic scale on the vertical axis and a linear scale on the horizontal axis.

Other examples that illustrate the use of semilogy are in these sections:

Curve Fitting for Error Rate Plots

Curve fitting is useful when you have a small or imperfect data set but want to plot a smooth curve for presentation purposes. The berfit function in Communications Toolbox offers curve-fitting capabilities that are well suited to the situation when the empirical data describes error rates at different Eb/N0 values. This function enables you to

For a full list of inputs and outputs for berfit, see its reference page.

Example: Curve Fitting for an Error Rate Plot

This example simulates a simple DBPSK (differential binary phase shift keying) communication system and plots error rate data for a series of Eb/N0 values. It uses the berfit function to fit a curve to the somewhat rough set of empirical error rates. Because the example is long, this discussion presents it in multiple steps:

Setting Up Parameters for the Simulation

The first step in the example sets up the parameters to be used during the simulation. Parameters include the range of Eb/N0 values to consider and the minimum number of errors that must occur before the simulation computes an error rate for that Eb/N0 value.

% Set up initial parameters.
siglen = 100000; % Number of bits in each trial
M = 2; % DBPSK is binary.
hMod = modem.dpskmod('M', M); % Create a DPSK modulator
hDemod = modem.dpskdemod(hMod); % Create a DPSK
                   % demodulator using the modulator object
EbNomin = 0; EbNomax = 9; % EbNo range, in dB
numerrmin = 5; % Compute BER only after 5 errors occur.
EbNovec = EbNomin:1:EbNomax; % Vector of EbNo values
numEbNos = length(EbNovec); % Number of EbNo values
% Preallocate space for certain data.
ber = zeros(1,numEbNos); % BER values
intv = cell(1,numEbNos); % Cell array of confidence intervals

Simulating the System Using a Loop

The next step in the example is to use a for loop to vary the Eb/N0 value (denoted by EbNo in the code) and simulate the communication system for each value. The inner while loop ensures that the simulation continues to use a given EbNo value until at least the predefined minimum number of errors has occurred. When the system is very noisy, this requires only one pass through the while loop, but in other cases, this requires multiple passes.

The communication system simulation uses these toolbox functions:

As the example progresses through the for loop, it collects data for later use in curve fitting and plotting:

% Loop over the vector of EbNo values.
for jj = 1:numEbNos
   EbNo = EbNovec(jj);
   snr = EbNo; % Because of binary modulation
   ntrials = 0; % Number of passes through the while loop below
   numerr = 0; % Number of errors for this EbNo value
   % Simulate until numerrmin errors occur.
   while (numerr < numerrmin)
      msg = randint(siglen, 1, M); % Generate message sequence.
      txsig = modulate(hMod, msg); % Modulate.
      rxsig = awgn(txsig, snr, 'measured'); % Add noise.
      decodmsg = demodulate(hDemod, rxsig); % Demodulate.
      if (ntrials==0)
         % The first symbol of a differentially encoded transmission
         % is discarded.
         newerrs = biterr(msg(2:end),decodmsg(2:end)); ...
% Errors in this trial
      else
         newerrs = biterr(msg,decodmsg); % Errors in this trial
      end
      numerr = numerr + newerrs; % Total errors for this EbNo value
      ntrials = ntrials + 1; % Update trial index.
   end
   % Error rate and 98% confidence interval for this EbNo value
   [ber(jj), intv1] = berconfint(numerr,(ntrials * siglen)-1,.98);
   intv{jj} = intv1; % Store in cell array for later use.
   disp(['EbNo = ' num2str(EbNo) ' dB, ' num2str(numerr) ...
         ' errors, BER = ' num2str(ber(jj))])
end

This part of the example displays output in the Command Window as it progresses through the for loop. Your exact output might be different, because this example uses random numbers.

EbNo = 0 dB, 189 errors, BER = 0.18919
EbNo = 1 dB, 139 errors, BER = 0.13914
EbNo = 2 dB, 105 errors, BER = 0.10511
EbNo = 3 dB, 66 errors, BER = 0.066066
EbNo = 4 dB, 40 errors, BER = 0.04004
EbNo = 5 dB, 18 errors, BER = 0.018018
EbNo = 6 dB, 6 errors, BER = 0.006006
EbNo = 7 dB, 11 errors, BER = 0.0055028
EbNo = 8 dB, 5 errors, BER = 0.00071439
EbNo = 9 dB, 5 errors, BER = 0.00022728
EbNo = 10 dB, 5 errors, BER = 1.006e-005

Plotting the Empirical Results and the Fitted Curve

The final part of this example fits a curve to the BER data collected from the simulation loop. It also plots error bars using the output from the berconfint function.

% Use BERFIT to plot the best fitted curve,
% interpolating to get a smooth plot.
fitEbNo = EbNomin:0.25:EbNomax; % Interpolation values
berfit(EbNovec,ber,fitEbNo,[],'exp');

% Also plot confidence intervals.
hold on;
for jj=1:numEbNos
   semilogy([EbNovec(jj) EbNovec(jj)],intv{jj},'g-+');
end
hold off;

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS