binaryVectorToDecimal

Convert binary vector value to decimal value

Description

example

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

binaryVectorToDecimal([1 1 0])
ans =

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

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

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

     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

Introduced in R2012b