# hex2poly

Convert hexadecimal character vector to binary coefficients

## Syntax

``b = hex2poly(hex)``
``b = hex2poly(hex,ord)``

## Description

example

````b = hex2poly(hex)` converts a hexadecimal character vector, `hex`, to a vector of binary coefficients, `b`. ```
````b = hex2poly(hex,ord)` specifies the power order, `ord`, of the coefficients that comprise the output. If omitted, `ord` is `'descending'`.```

## Examples

collapse all

Convert the hexadecimal polynomial `'1AF'` to a vector of binary coefficients. The coefficients represent the polynomial ${x}^{8}+{x}^{7}+{x}^{5}+{x}^{3}+{x}^{2}+x+1$.

`b = hex2poly('1AF')`
```b = 1×9 1 1 0 1 0 1 1 1 1 ```

Convert hexadecimal `'0x82608EDB'` to a vector of binary coefficients. Specify that the binary coefficients are in ascending order.

`b = hex2poly('0x82608EDB','ascending')`
```b = 1×32 1 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 ```

The binary representation corresponds to a polynomial of ${x}^{31}+{x}^{25}+{x}^{22}+{x}^{21}+{x}^{15}+{x}^{11}+{x}^{10}+{x}^{9}+{x}^{7}+{x}^{6}+{x}^{4}+{x}^{3}+x+1$.

## Input Arguments

collapse all

Hexadecimal number, specified as a character vector.

Example: `'FF'`

Example: `'0x3FA'`

Data Types: `char`

Power order of the vector of binary coefficients, specified as a character vector having a value of `'ascending'` or `'descending'`.

Data Types: `char`

## Output Arguments

collapse all

Binary coefficients representing a polynomial, returned as a row vector having length equal to p + 1, where p is the order of hexadecimal input.

## Version History

Introduced in R2015b