计算二进制比特流的汉明距以及误码率, biterr Compute number of bit errors and bit error rate.
语法形式如下:
[num,ratio] = biterr(X,Y) ,
num表示参数X和Y(十进制数)对应二进制比特流对应位置二进制数不相同的位数之和,称为汉明距
ratio表示两者的汉明距占输入参数中最大值以二进制表示的最少比特位数的比例,称为误码率。
有点绕,举例如下
>>> help biterr
>>>
[NUMBER,RATIO] = biterr(X,Y) compares the unsigned binary representation of
the elements in the two matrices X and Y. X and Y must be logical or
integer valued. The number of differences in the binary representation is
output in NUMBER. The ratio of NUMBER to the total number of bits used in
the binary representation is output in RATIO. The same number of bits is
used to represent each element in both X and Y. The number of bits used is
the smallest number required to represent the largest element in either X or
Y. When one of the inputs is a matrix and the other is a vector the
function performs either a column-wise or row-wise comparison based on the
orientation of the vector.
exam1中的参数均为scale标量,将其转为8位二进制为"01010101", “01110110” ,但以二进制表示两者参数的最大数所需要的最少比特位数为7,即"1010101", “1110110” ,对应文档中The number of bits used is the smallest number required to represent the largest element in either X or Y. 显然,两者不等的个数有3位,即汉明距=3, 误码率为3/7, 约等于0.4286