# binaryVectorToDecimal

Convert binary vector value to decimal value

## Syntax

``decVal = binaryVectorToDecimal(binaryVector)``
``binaryVectorToDecimal(binaryVector,bitOrder)``

## Description

This function is part of Data Acquisition Toolbox™, and converts binary data represented by a vector of 1s and 0s. To convert binary data from a string or character vector, you can use the MATLAB® function `bin2dec`.

````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.```

example

## 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 1 0],'LSBFirst')`
```decVal = 3```
`decVal = binaryVectorToDecimal([1 0 0 0; 0 1 0 0],'LSBFirst')`
```decVal = 1 2```

## 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.

## Version History

Introduced in R2012b