Main Content

symerr

Compute number of symbol errors and symbol error rate

Description

[number,ratio] = symerr(x,y) compares the elements in x and y. The sizes of x and y determine which elements are compared. The output number is a scalar or vector that indicates the number of elements that differ. The output ratio equals number divided by the total number of elements in the smaller input.

example

[number,ratio] = symerr(x,y,flg) compares the elements in x and y. Optional input flg and the size of x, and y, determine the size of number.

[number,ratio,individual] = symerr(...) returns a binary matrix individual that indicates which elements of x and y differ. An element of individual is zero if the corresponding comparison yields no discrepancy, and one otherwise.

example

Examples

collapse all

Compare Elements of Matrix with Another Matrix

x = [1,1,3,1;3,2,2,2;3,3,8,3]
x = 3×4

     1     1     3     1
     3     2     2     2
     3     3     8     3

aMatrix = [1,1,1,1;2,2,2,2;3,3,3,3]
aMatrix = 3×4

     1     1     1     1
     2     2     2     2
     3     3     3     3

[number1,ratio1] = symerr(x,aMatrix)
number1 = 
3
ratio1 = 
0.2500

Compare Elements of Matrix with Row Vector

x = [1,1,3,1;3,2,2,2;3,3,8,3]
x = 3×4

     1     1     3     1
     3     2     2     2
     3     3     8     3

aRowVector = [1,2,3,1]
aRowVector = 1×4

     1     2     3     1

[number2,ratio2] = symerr(x,aRowVector)
number2 = 3×1

     1
     3
     4

ratio2 = 3×1

    0.2500
    0.7500
    1.0000

Compare Elements of Matrix with Column Vector

x = [1,1,3,1;3,2,2,2;3,3,8,3]
x = 3×4

     1     1     3     1
     3     2     2     2
     3     3     8     3

aColumnVector = [1;2;3]
aColumnVector = 3×1

     1
     2
     3

[number3,ratio3] = symerr(x,aColumnVector)
number3 = 1×4

     1     0     2     0

ratio3 = 1×4

    0.3333         0    0.6667         0

You can specify alternative comparison methods used by symerr. In this example, you use a flag to override the default row-by-row comparison. Notice that number and ratio are scalars.

format rat;
[number,ratio,loc] = symerr([1 2; 3 4],[1 3],'overall')
number = 
       3       

ratio = 
       3/4     

loc = 2×2 logical array

   0   1
   1   1

Input Arguments

collapse all

First input to compare, specified as a vector, or a matrix.

Data Types: double

Second input to compare, specified as a vector, or a matrix.

Data Types: double

Optional argument to override the defaults that govern which elements symerr compares and how symerr computes the outputs.

  • 'overall' –– x and y are compared element by element.

  • 'column-wise' –– mth row of x vs. mth row of y.

  • 'row-wise' –– mth column of x vs. mth column of y.

For more information, see the Specifying Element Comparison section.

Output Arguments

collapse all

Number of elements that differ between x and y, returned as a scalar or vector. The size of number is determined by the optional input flg and by the dimensions of x and y. For more information, see the Default Element Comparison and Specifying Element Comparison sections.

The ratio of the number of differing elements, number, and the total number of elements of the smaller input, returned as a scalar.

Results of each individual symbol comparison, returned as a matrix of same size and dimensions as inputs x and y. The output matrix contains zeros for all locations corresponding to the elements of x and y that are equal, and ones where the two elements differ.

Data Types: logical

More About

collapse all

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a