Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

binaryVectorToDecimal

Convert binary vector value to decimal value

Syntax

binaryVectorToDecimal(binaryVector)
binaryVectorToDecimal(binaryVector,bitOrder)

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

Was this topic helpful?