Documentation

comm.ErrorRate System object

Compute bit or symbol error rate of input data

Description

TheErrorRateobject 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. SeeConstruction.

  2. Callstepto compare input data from a transmitter with input data from a receiver and calculate the error rate according to the properties ofcomm.ErrorRate. The behavior ofstepis specific to each object in the toolbox.

Note

Starting in R2016b, instead of using thestepmethod to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example,y = step(obj,x)andy = obj(x)perform equivalent operations.

Construction

H = comm.ErrorRatecreates 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).

Properties

ReceiveDelay

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 is0.

ComputationDelay

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 is0.

Samples

Samples to consider

Specify samples to consider as one ofEntire 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 isEntire frame. SelectEntire frameto compare all the samples of the RX frame to those of the TX frame. SelectCustomorInput portto list the indices of the RX frame elements that the object should consider when making comparisons. When you set this property toCustom, you can list the indices as a scalar or a column vector of double-precision integers through theCustomSamplesproperty. When you set this property toInput port, you can list the indices as an input to thestepmethod.

CustomSamples

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 theSamplesproperty toCustom. The default is an empty vector, which specifies that all samples are used.

ResetInputPort

Enable error rate reset input

Set this property totrueto reset the error statistics via an input to thestepmethod. The default isfalse.

Methods

reset Reset states of error rate calculator object
step Compute bit or symbol error rate of input data
Common to All System Objects
release

Allow System object property value changes

Examples

expand all

Create two binary vectors and determine the error statistics.

Create a bit error rate counter object.

errorRate = 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) = ~y(1); y(end) = ~y(end);

计算呃ror statistics.

z = errorRate(x,y);

The first element of the vectorzis the bit error rate.

z(1)
ans = 0.2000

The second element ofzis the total error count.

z(2)
ans = 2

The third element ofzis the total number of bits.

z(3)
ans = 10

Create an 8-DPSK modulator and demodulator pair that work with binary data.

dpskModulator = comm.DPSKModulator('ModulationOrder',8,'BitInput',true); dpskDemodulator = comm.DPSKDemodulator('ModulationOrder',8,'BitOutput',true);

Create an error rate calculator, accounting for the three bit (one symbol) transient caused by the differential modulation.

errorRate = comm.ErrorRate('ComputationDelay',3);

Calculate the BER for 10 frames.

BER = zeros(10,1);fori= 1:10 txData = randi([0 1],96,1);% Generate binary datamodData = dpskModulator(txData);% ModulaterxSig = awgn(modData,7);% Pass through AWGN channelrxData = dpskDemodulator(rxSig);% Demodulateerrors = errorRate(txData,rxData);% Compute error statisticsBER(i) = errors(1);% Save BER dataend

Display the BER.

BER
BER =10×10.1613 0.1640 0.1614 0.1496 0.1488 0.1309 0.1405 0.1399 0.1370 0.1411

Algorithms

这个对象实现该算法,输入,outputs described on theError Rate Calculationblock reference page. The object properties correspond to the block parameters, except:

  • TheOutput dataandVariable nameblock parameters do not have a corresponding properties. The object always returns the result as an output.

  • The停止仿真block parameter does not have a corresponding property. To implement similar behavior, use the output of thestepmethod in a while loop, to programmatically stop the simulation. See theGray Coded 8-PSK.

  • TheComputation modeparameter corresponds to theSamplesandCustomSamplesproperties.

Extended Capabilities

Introduced in R2012a

Was this topic helpful?