symerr
Compute number of symbol errors and symbol error rate
Syntax
Description
[
compares the elements in number
,ratio
] = symerr(x
,y
)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.
[
returns a binary matrix number
,ratio
,individual
] = symerr(...)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.
Examples
Compare Elements of Matrix
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
Use Alternative Type of Comparison
You can specify alternative comparison methods used by symerr
. In this example, you use a flag to override the default rowbyrow 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 = 2x2 logical array
0 1
1 1
Input Arguments
x
— First input to compare
scalar  vector  matrix
First input to compare, specified as a vector, or a matrix.
Data Types: double
y
— Second input to compare
scalar  vector  matrix
Second input to compare, specified as a vector, or a matrix.
Data Types: double
flg
— Element comparison type
'overall'
 'columnwise'
 'rowwise'
Optional argument to override the defaults that govern which elements
symerr
compares and how symerr
computes the outputs.
'overall'
––x
andy
are compared element by element.'columnwise'
–– m^{th} row ofx
vs. m^{th} row ofy
.'rowwise'
–– m^{th} column ofx
vs. m^{th} column ofy
.
For more information, see the Specifying Element Comparison section.
Output Arguments
number
— Number of differing elements
scalar  vector
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.
ratio
— Ratio of differing elements
scalar
The ratio of the number of differing elements, number
,
and the total number of elements of the smaller input,
returned as a scalar.
individual
— Results of each individual symbol comparison
matrix
More About
Default Element Comparison
The symerr
function compares binary
representations of elements in x
with those in
y
. When optional argument flg
is
not specified, symerr
uses the shape of the inputs
x
and y
to determine the element
comparison method.
The schematics below illustrate how the shapes of
x
and y
determine which elements
symerr
compares:
If
x
andy
are matrices of the same dimensions, thensymerr
comparesx
andy
element by element.number
is a scalar. See schematic (a) in the figure.If one is a row (respectively, column) vector and the other is a twodimensional matrix, then
symerr
compares the vector element by element with each row (resp., column) of the matrix. The length of the vector must equal the number of columns (resp., rows) in the matrix.number
is a column (resp., row) vector whose mth entry indicates the number of elements that differ when comparing the vector with the mth row (resp., column) of the matrix. See schematics (b) and (c) in the figure.
Specifying Element Comparison
Use flg
to override the defaults that
govern which elements symerr
compares and how
symerr
computes the outputs. The values of
flg
are 'overall'
,
'columnwise'
, and 'rowwise'
. The table
below describes the differences that result from various combinations of inputs. In
all cases, ratio
is number
divided by the
total number of elements in y
.
Comparing a TwoDimensional Matrix x with Another Input y
Shape of y  flg  Type of Comparison  number 

Twodim. matrix  'overall' (default)  Element by element  Total number of symbol errors 
'columnwise'  m^{th} column of
x vs.
m^{th} column of
y
 Row vector whose entries count symbol errors in each column  
'rowwise'  m^{th} row of
x vs.
m^{th} row of
y
 Column vector whose entries count symbol errors in each row  
Column vector  'overall'
 y vs. each column of x
 Total number of symbol errors 
'columnwise' (default)  y vs. each column of x
 Row vector whose entries count symbol errors in each column
of x
 
Row vector  'overall'  y vs. each row of x
 Total number of symbol errors 
'rowwise' (default)  y vs. each row of x
 Column vector whose entries count symbol errors in each row
of x

Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced before R2006a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)