comm.ErrorRate System object

Package: comm

Compute bit or symbol error rate of input data


The ErrorRate object compares input data from a transmitter with input data from a receiver and calculates the error rate as a running statistic. To obtain the error rate, the object divides the total number of unequal pairs of data elements by the total number of input data elements from one source.

To obtain the error rate:

  1. Define and set up your error rate object. See Construction.

  2. Call step to compare input data from a transmitter with input data from a receiver and calculate the error rate according to the properties of comm.ErrorRate. The behavior of step is specific to each object in the toolbox.


H = comm.ErrorRate creates an error rate calculator System object™, H. This object computes the error rate of the received data by comparing it to the transmitted data.

H = comm.ErrorRate(Name,Value) creates an error rate calculator object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).



Number of samples to delay transmitted signal

Specify the number of samples by which the received data lags behind the transmitted data. This value must be a real, nonnegative, double-precision, integer scalar. Use this property to align the samples for comparison in the transmitted and received input data vectors. Specify the delay in number of samples, regardless of whether the input is a scalar or a vector. The default is 0.


Computation delay

Specify the number of data samples that the object should ignore at the beginning of the comparison. This value must be a real, nonnegative, double-precision, integer scalar. Use this property to ignore the transient behavior of both input signals. The default is 0.


Samples to consider

Specify samples to consider as one of Entire frame | Custom | Input port. The property defines whether the object should consider all or only part of the input frames when computing error statistics. The default is Entire frame. Select Entire frame to compare all the samples of the RX frame to those of the TX frame. Select Custom or Input port to list the indices of the RX frame elements that the object should consider when making comparisons. When you set this property to Custom, you can list the indices as a scalar or a column vector of double-precision integers through the CustomSamples property. When you set this property to Input port, you can list the indices as an input to the step method.


Selected samples from frame

Specify a scalar or a column vector of double-precision, real, positive integers. This value lists the indices of the elements of the RX frame vector that the object uses when making comparisons. This property applies when you set the Samples property to Custom. The default is an empty vector, which specifies that all samples are used.


Enable error rate reset input

Set this property to true to reset the error statistics via an input to the step method. The default is false.


cloneCreate error rate calculator object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset states of error rate calculator object
stepCompute bit or symbol error rate of input data


expand all

Calculate Error Statistics

Create two binary vectors and determine the error statistics.

Create a bit error rate counter object.

err = comm.ErrorRate;

Create an arbitrary binary data vector.

x = [1 0 1 0 1 0 1 0 1 0]';

Introduce errors to the first and last bits.

y = x;
y(1) = 0;
y(end) = 1;

Using the step method, calculate the error statistics.

z = step(err,x,y);

The first element of the vector z is the bit error rate.

ans =


The second element of z is the total error count.

ans =


The third element of z is the total number of bits.

ans =


Calculate BER between transmitted and received signal

Use 8-DPSK modulation in an AWGN channel

    hMod = comm.DPSKModulator('ModulationOrder',8,'BitInput',true);
    hDemod = comm.DPSKDemodulator('ModulationOrder',8,'BitOutput',true);
    hAWGN = comm.AWGNChannel('NoiseMethod',...
                         'Signal to noise ratio (SNR)','SNR', 7);

% Create an error rate calculator, accounting for the three bit
% (i.e., one symbol) transient caused by the differential modulation
    hError = comm.ErrorRate('ComputationDelay',3);
    BER = zeros(10,1);

% Calculate BER for 10 frames
    for i= 1:10
        data = randi([0 1], 96, 1);
        modData = step(hMod, data);
        receivedSignal = step(hAWGN, modData);
        receivedData = step(hDemod, receivedSignal);
        errors = step(hError, data, receivedData);
        BER(i) = errors(1);
    disp(BER) % display BER for 10 frames


This object implements the algorithm, inputs, and outputs described on the Error Rate Calculation block reference page. The object properties correspond to the block parameters, except:

  • The Output data and Variable name block parameters do not have a corresponding properties. The object always returns the result as an output.

  • The Stop simulation block parameter does not have a corresponding property. To implement similar behavior, use the output of the step method in a while loop, to programmatically stop the simulation. See the Gray Coded 8-PSK.

  • The Computation mode parameter corresponds to the Samples and CustomSamples properties.

Introduced in R2012a

Was this topic helpful?