Documentation

### This is machine translation

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

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

# binaryVectorToHex

Convert binary vector value to hexadecimal

## Syntax

``hexval = binaryVectorToHex(binaryVector)``
``hexval = binaryVectorToHex(binaryVector,bitOrder)``

## Description

example

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

example

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

## Examples

collapse all

`hexval = binaryVectorToHex([0 0 1 1 1 1 0 1])`
```hexval = 3D```
`hexval = binaryVectorToHex([1 1 0 0 0 1 0 0 ; 0 0 0 0 1 0 1 0])`
```hexval = 'C4' '0A'```

The output is appended with 0s to make all hex values the same length character vectors.

`hexval = binaryVectorToHex([0 0 1 1 1 1 0 1],'LSBFirst')`
```hexval = BC```
`hexval = binaryVectorToHex([1 1 0 0 0 1 0 0 ; 0 0 0 0 1 0 1 0],'LSBFirst')`
```hexval = '23' '50'```

If necessary, the output is appended with 0s to make all hex values the same length character vectors.

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

## Input Arguments

collapse all

The binary vector to convert to hexadecimal specified as a numeric vector with 0s and 1s. The vector can be a column or row vector.

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

Hexadecimal value returned as a character vector.