hexToBinaryVector

Convert hexadecimal value to binary vector

Syntax

• `hexToBinaryVector(hexNumber)` example
• `hexToBinaryVector(hexNumber,numberOfBits)` example
• `hexToBinaryVector(hexNumber,numberOfBits,bitOrder)` example

Description

example

````hexToBinaryVector(hexNumber)` converts hexadecimal numbers to a binary vector.```

example

````hexToBinaryVector(hexNumber,numberOfBits)` converts hexadecimal numbers to a binary vector with the specified number of bits.```

example

````hexToBinaryVector(hexNumber,numberOfBits,bitOrder)` converts hexadecimal numbers to a binary vector with the specified number of bits in the specified bit ordering.```

Examples

collapse all

Convert a hexadecimal to a binary vector

```hexToBinaryVector('A1') ```
```ans= 1 0 1 0 0 0 0 1```

Convert a hexadecimal with a leading 0 to a binary Vector

`hexToBinaryVector('0xA')`
```ans= 1 0 1 0```

Convert an array hexadecimal numbers to a binary vector

```hexToBinaryVector(['A1'; 'B1']) ```
```ans= 1 0 1 0 0 0 0 1 1 0 1 1 0 0 0 1```

Convert a hexadecimal number into a binary vector of specific bits

```hexToBinaryVector('A1',12, 'MSBFirst') ```
```ans= 0 0 0 0 1 0 1 0 0 0 0 1```

Convert a cell array of hexadecimal numbers into a binary vector of specific bits

```hexToBinaryVector({'A1';'B1'},8) ```
```ans= 1 0 1 0 0 0 0 1 1 0 1 1 0 0 0 1```

Convert a hexadecimal into a binary vector with LSB first

```hexToBinaryVector('A1', [], 'LSBFirst') ```
```ans= 1 0 0 0 0 1 0 1```

Input Arguments

collapse all

`hexNumber` — Hexadecimal to convert to binary vectorhexadecimal

Hexadecimal number to convert to a binary vector specified as a character or an array.

`numberOfBits` — Number of bits required to correctly represent the decimal numbernumeric

This is an optional argument. If you do not specify the number of bits, the number is represented using the minimum number of bits needed.

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

Get trial now