Communications Toolbox    
bi2de

Convert binary vectors to decimal numbers

Syntax

Description

dbi2de(b) converts a binary row vector b to a nonnegative decimal integer. If b is a matrix, then each row is interpreted separately as a binary number. In this case, the output d is a column vector, each element of which is the decimal representation of the corresponding row of b.

d = bi2de(b,flg) is the same as the syntax above, except that flg is a string that determines whether the first column of b contains the lowest-order or highest-order digits. Possible values for flg are 'right-msb' and 'left-msb'. The value 'right-msb' produces the default behavior.

d = bi2de(b,p) converts a base-p row vector b to a nonnegative decimal integer , where p is an integer greater than or equal to 2. The first column of b is the lowest base-p digit. If b is a matrix, then the output d is a nonnegative decimal vector, each row of which is the decimal form of the corresponding row of b.

d = bi2de(b,p,flg) is the same as the syntax above, except that flg is a string that determines whether the first column of b contains the lowest-order or highest-order digits. Possible values for flg are 'right-msb' and 'left-msb'. The value 'right-msb' produces the default behavior.

Examples

The code below generates a matrix that contains binary representations of five random numbers between 0 and 15. It then converts all five numbers to decimal integers.

Sample output is below. Your results might vary because the numbers are random.

The command below converts a base-five number into its decimal counterpart, using the leftmost base-five digit (4 in this case) as the most significant digit. The example reflects the fact that 4(53) + 2(52) +50 = 551.

See Also
de2bi


  bchpoly biterr