| Communications Blockset™ | ![]() |
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.
You can 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.
This block inherits the sample time of its inputs.
Note This block does not generate C code when the block parameter Output data is set to Workspace. Consider changing Output data to Port instead. |
This block has between two and four input ports, depending on how you set the dialog parameters. The inports 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 inputs can be either scalars or frame-based column vectors of fixed-point data type, or int8, uint8, int16, uint16, int32, uint32, boolean, single, or double. 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. (Overall, the block behaves as if you had preprocessed the scalar signal with the Communications Blockset™ Repeat block using the Maintain input frame rate option.)
If you check the Reset port box, then an additional inport appears, labeled Rst. The Rst input must be a sample-based scalar signal (of type double or boolean) and must have the same sampling rate as the Tx and Rx signals. When the Rst input is nonzero, the block clears its error statistics and then computes them anew.
If you set the Computation mode parameter to Select samples from port, then an additional inport appears, labeled Sel. The Sel input indicates which elements of a frame are relevant for the computation; this is explained further, in the last subbullet below. The Sel input can be either a sample-based column vector or a one-dimensional 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. You should leave the Computation mode parameter at its 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 this block compares the scalar with each entry of the vector. The three subbullets above are still valid for this mode, except that if Rx is a scalar, then the phrase "Rx frame" above refers to the vector expansion of Rx.
Note Simulink requires that input signals have constant length throughout a simulation. 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, comparisons between unequal elements
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 Real-Time Workshop® software, then you should not use the Workspace option; instead, use the Port option below and connect the output port to a Simulink To Workspace 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 is useful when part of your model causes a lag in the received data, and the other is useful when you want to ignore the transient behavior of both input signals:
The Receive delay parameter is the number of samples by which the received data lags behind the transmitted data. This parameter tells the block which samples "correspond" to each other and should be compared. The receive delay persists throughout the simulation.
The Computation delay parameter tells the block to ignore the specified number of samples at the beginning of the comparison.
If you do not know the receive delay in your model, you can use the Align Signals block, which automatically compensates for the delay. If you use the Align Signals block, you should set the Receive delay in the Error Rate Calculation block to 0.
Alternatively, you can use the Find Delay block to find the value of the delay, and then set the Receive delay parameter in the Error Rate Calculation block to that value.
Note The Version 1.4 Error Rate Calculation block considers a vector input to be a sample, whereas the current block considers a vector input to be a frame of multiple samples. For vector inputs of length n, a Receive delay of k in the Version 1.4 block is equivalent to a Receive delay of k*n in the current 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.
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 the Stop simulation check box. The block attempts to run the simulation until it detects Target number of errors errors. 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.
The figure below shows how the block compares pairs of elements and counts the number of error events. 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
The input signals are both frame-based 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.

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.

If you use the Real-Time Workshop 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.

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.
![]() | Early-Late Gate Timing Recovery | Find Delay | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |