binaryVectorToHex

Convert binary vector value to hexadecimal

Syntax

  • binaryVectorToHex(binaryVector) example
  • binaryVectorToHex(binaryVector,bitOrder) example

Description

example

binaryVectorToHex(binaryVector) converts the input binary vector to a hexadecimal.

example

binaryVectorToHex(binaryVector,bitOrder) converts the input binary vector using the specified bit orientation.

Examples

expand all

Convert a Binary Vector to a Hexadecimal

binaryVectorToHex([0 0 1 1 1 1 0 1])
ans =

     3D

Convert an Array of Binary Vectors to a Hexadecimal

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

    'C4'
    '0A'

The output is appended with 0s to make all hex values same length strings.

Convert a Binary Vector with LSB First

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

     BC

Convert a Binary Vector Array with LSB First

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

    '23'
    '50'

The output is appended with 0s to make all hex values same length strings.

    Note:   The binary vector array is converted to a cell array of hexadecimal numbers. If you input a single binary vector, it is converted to a hexadecimal string.

Input Arguments

expand all

binaryVector — Binary vector to convert to hexadecimalbinary vector

The binary vector to convert to hexadecimal specified as a row vector with 0s and 1s. It can also be a 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?