# 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 = 2×1 cell array {'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 = 2×1 cell array {'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

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. Multiple values are returned as a cell array of character vectors.

### Topics

Introduced in R2012b

평가판 신청