binaryVectorToDecimal

Convert binary vector value to decimal value

Description

example

decVal = binaryVectorToDecimal(binaryVector) converts a binary vector to a decimal.

example

binaryVectorToDecimal(binaryVector,bitOrder) converts a binary vector with the specified bit orientation to a decimal .

Examples

collapse all

decVal = binaryVectorToDecimal([1 1 0])
decVal =

     6
decVal = binaryVectorToDecimal([1 0 0 0; 0 1 0 0])
decVal =

     8
     4
decVal = binaryVectorToDecimal([1 0 0 0; 0 1 0 0],'LSBFirst')
decVal =

     1
     2
decVal = binaryVectorToDecimal([1 1 0],'LSBFirst')
decVal =

     6

Input Arguments

collapse all

Binary vector to convert to a decimal, specified as a single binary vector or a row or column-based array of binary vectors.

Bit order for the binary vector representation, specified as a character vector or string. Accepted values are:

  • 'MSBFirst' — The first element of the binary vector is the most significant bit.

  • 'LSBFirst' — The first element of the binary vector is the least significant bit.

Data Types: char | string

Output Arguments

collapse all

Decimal value, returned as a double.

Introduced in R2012b