Compute bit error rate or symbol error rate of input data
Comm Sinks
The Error Rate Calculation block compares input data from a transmitter with input data from a receiver. It calculates the error rate as a running statistic, by dividing the total number of unequal pairs of data elements by the total number of input data elements from one source.
Use this block to compute either symbol or bit error rate, because it does not consider the magnitude of the difference between input data elements. If the inputs are bits, then the block computes the bit error rate. If the inputs are symbols, then it computes the symbol error rate.
Note
When you set the Output data parameter to
Workspace
, the block generates no code. Similarly, no
data is saved to the workspace if the Simulation mode is set to
Accelerator
or Rapid
Accelerator
. If you need error rate information in these cases,
set Output data to Port
.
This block has between two and four input ports, depending on how you set the
dialog parameters. The input ports marked Tx
and
Rx
accept transmitted and received signals, respectively. The
Tx
and Rx
signals must share the same
sampling rate.
The Tx
and Rx
input ports accept scalar or
column vector signals. For information about the data types each block port
supports, see the Supported Data Types table on this page.
If Tx
is a scalar and Rx
is a vector, or
vice-versa, then the block compares the scalar with each element of the vector. In
this case, the block behaves as if you had preprocessed the scalar signal by using
the Repeat block with the Rate
options parameter set to Enforce single
rate
.
If you select Reset port, then an additional input port
appears, labeled Rst
. The Rst
input accepts
only a scalar signal (of type double
or
boolean
) and must have the same port sample time as the
Tx
and Rx
ports. When the
Rst
input is nonzero, the block clears and then recomputes
the error statistics.
If you set the Computation mode parameter to
Select samples from port
, then an additional input
port appears, labeled Sel
. The Sel
input
indicates which elements of a frame are relevant for the computation. The
Sel
input can be a column vector of type
double
.
The guidelines below indicate how you should configure the inputs and the dialog
parameters depending on how you want this block to interpret your
Tx
and Rx
data.
If both data signals are scalar, then this block compares the
Tx
scalar signal with the Rx
scalar signal. For this configuration, use the Computation
mode parameter default value, Entire
frame
.
If both data signals are vectors, then this block compares some or all of
the Tx
and Rx
data:
If you set the Computation mode parameter to
Entire frame
, then the block compares
all of the Tx
frame with all of the
Rx
frame.
If you set the Computation mode parameter to
Select samples from mask
, then the
Selected samples from frame field appears
in the dialog. This parameter field accepts a vector that lists the
indices of those elements of the Rx
frame that
you want the block to consider. For example, to consider only the
first and last elements of a length-six receiver frame, set the
Selected samples from frame parameter to
[1 6]
. If the Selected samples from
frame vector includes zeros, then the block ignores
them.
If you set the Computation mode parameter to
Select samples from port
, then an
additional input port, labeled Sel
, appears on
the block icon. The data at this input port must have the same
format as that of the Selected samples from
frame parameter described above.
If one data signal is a scalar and the other is a vector, then the scalar
is with each entry of the vector. In this case, if Rx
is
a scalar, then the phrase “Rx
frame” above
refers to the vector expansion of Rx
.
Note
This block does not support variable-size signals. If you choose the
Select samples from port
option and want
the number of elements in the subframe to vary during the simulation,
then you should pad the Sel
signal with zeros. The
Error Rate Calculation block ignores zeros in the Sel
signal.
This block produces a vector of length three, whose entries correspond to:
The error rate
The total number of errors, that is, the number of instances that an Rx element does not match the corresponding Tx element
The total number of comparisons that the block made
The block sends this output data to the base MATLAB® workspace or to an output port, depending on how you set the Output data parameter:
If you set the Output data parameter to
Workspace
and fill in the Variable
name parameter, then that variable in the base MATLAB
workspace contains the current value when the simulation
ends. Pausing the simulation does not cause the
block to write interim data to the variable.
If you plan to use this block along with the Simulink®
Coder™ software, then you should not use the
Workspace
option. Instead, use the
Port
option and connect the output port to a
Simulink
To Workspace (Simulink) block.
If you set the Output data parameter to
Port
, then an output port appears. This
output port contains the running error
statistics.
The Receive delay and Computation delay parameters implement two different types of delays for this block. One delay is useful if you want this block to compensate for the delay in the received signal. The other is useful if you want to ignore the initial transient behavior of both input signals.
The Receive delay parameter represents the number of samples by which the received data lags behind the transmitted data. The transmit signal is implicitly delayed by that same amount before the block compares it to the received data. This value is helpful when you delay the transmit signal so that it aligns with the received signal. The receive delay persists throughout the simulation.
The Computation delay parameter represents the number of samples the block ignores at the beginning of the comparison.
Use the Find Delay block to determine the delay, and then set the Receive delay to the delay reported by the Find Delay block.
If you use the Select samples from mask
or
Select samples from port
option, then each delay
parameter refers to the number of samples that the block receives, whether the block
ultimately ignores some of them or not.
If using the Sel port to calculate errors on a delayed signal, the delay must be added to the Sel indices. For more information, see Calculate Errors for Delayed Selected Samples.
You can configure this block so that its error statistics control the duration of simulation. This is useful for computing reliable steady-state error statistics without knowing in advance how long transient effects might last. To use this mode, check Stop simulation. The block attempts to run the simulation until it detects the number of errors the Target number of errors parameter specifies. However, the simulation stops before detecting enough errors if the time reaches the model's Stop time setting (in the Configuration Parameters dialog box), if the Error Rate Calculation block makes Maximum number of symbols comparisons, or if another block in the model directs the simulation to stop.
To ignore either of the two stopping criteria in this block, set the corresponding
parameter (Target number of errors or Maximum number
of symbols) to Inf
. For example, to reach a target
number of errors without stopping the simulation early, set Maximum number
of symbols to Inf
and set the model's
Stop time to Inf
.
If you use the Simulink Coder rapid simulation (RSim) target to build an RSim executable, then you can tune the Target number of errors and Maximum number of symbols parameters without recompiling the model. This is useful for Monte Carlo simulations in which you run the simulation multiple times (perhaps on multiple computers) with different amounts of noise.
Full Frame Error Calculation
The figure below shows how the block compares pairs of elements and counts the number
of error events. The Tx
and Rx
inputs are column
vectors.
This example assumes that the sample time of each input signal is 1 second and that the block's parameters are as follows:
Receive delay = 2
Computation delay = 0
Computation mode = Entire
frame
Both input signals are column vectors of length three. However, the schematic arranges
each column vector horizontally and aligns pairs of vectors so as to reflect a receive
delay of two samples. At each time step, the block compares elements of the
Rx
signal with those of the Tx
signal that
appear directly above them in the schematic. For instance, at time 1, the block
compares 2, 4, and 1 from the Rx
signal with 2, 3, and 1 from
the Tx
signal.
The values of the first two elements of Rx
appear as asterisks
because they do not influence the output. Similarly, the 6 and 5 in the
Tx
signal do not influence the output up to time 3, though
they would influence the output at time 4.
In the error rates on the right side of the figure, each numerator at time
t reflects the number of errors when considering the elements
of Rx
up through time t.
Full Frame Error Calculation with Reset
If the block's Reset port box had been checked and a reset had
occurred at time = 3 seconds, then the last error rate would have been
2/3 instead of 4/10. This value 2/3 would reflect the comparison of 3, 2, and 1
from the Rx
signal with 7, 7, and 1 from the Tx
signal. The figure below illustrates this scenario. The Tx
and
Rx
inputs are column vectors.
Error Calculation on Selected Samples in the Frame
If using the Sel port to calculate errors on a delayed signal, the delay must be added to the Sel indices. For more information, see Calculate Errors for Delayed Selected Samples.
Number of samples by which the received data lags behind the transmitted
data. (If Tx
or Rx
is a vector, then
each entry represents a sample.)
Number of samples that the block should ignore at the beginning of the comparison.
Either Entire frame
, Select
samples from mask
, or Select samples from
port
, depending on whether the block should consider all
or only part of the input frames.
A vector that lists the indices of the elements of the
Rx
frame vector that the block should consider when
making comparisons. This field appears only if Computation
mode is set to Select samples from
mask
.
Either Workspace
or
Port
, depending on where you want to send the
output data.
Name of variable for the output data vector in the base MATLAB workspace.
This field appears only if Output data is set to
Workspace
.
If you check this box, then an additional input port appears, labeled
Rst
.
If you check this box, then the simulation runs only until this block detects a specified number of errors or performs a specified number of comparisons, whichever comes first.
The simulation stops after detecting this number of errors. This field is active only if Stop simulation is checked.
The simulation stops after making this number of comparisons. This field is active only if Stop simulation is checked.
Port | Supported Data Types |
---|---|
Tx |
|
Rx |
|
Sel |
|
Reset |
|