Documentation

binaryVectorToDecimal

Convert binary vector value to decimal value

Syntax

  • binaryVectorToDecimal(binaryVector) example
  • binaryVectorToDecimal(binaryVector,bitOrder) example

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

expand all

Convert Binary Vector to a Decimal Value

binaryVectorToDecimal([1 1 0])
ans =

     6

Convert a Binary Vector Array to a Decimal Value

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

     8
     4

Convert a Binary Vector with LSB First

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

     1
     2

Convert a Binary Vector Array with LSB First

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

     6

Input Arguments

expand all

binaryVector — Binary vector to convert to decimalbinary Vectors

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

bitOrder — Bit order for binary vector representationMSBFirst (default) | LSBFirst

Bit order for the binary vector representation specified as:

  • MSBFirst if you want the first element of the output to contain the most significant bit of the decimal number.

  • LSBFirst if you want the first element of the output to contain the least significant bit of the decimal number.

Was this topic helpful?