hex2num

Convert hexadecimal string to number using quantizer object

Syntax

x = hex2num(q,h)
[x1,x2,...] = hex2num(q,h1,h2,...)

Description

x = hex2num(q,h) converts hexadecimal character vector h to numeric matrix x. The attributes of the numbers in x are specified by quantizer object q. When h is a cell array, hex2num returns x as a cell array of the same dimension containing numbers. For fixed-point hexadecimal representations, hex2num uses two's complement representation. For floating-point, the representation is IEEE® Standard 754 style.

When there are fewer hexadecimal digits than needed to represent the number, the fixed-point conversion zero-fills on the left. Floating-point conversion zero-fills on the right.

[x1,x2,...] = hex2num(q,h1,h2,...) converts hexadecimal representations h1, h2,... to numeric matrices x1, x2,....

hex2num and num2hex are inverses of one another, with the distinction that num2hex returns the hexadecimal representations in a column.

Examples

To create all the 4-bit fixed-point two's complement numbers in fractional form, use the following code.

q = quantizer([4 3]);
h = ['7 3 F B';'6 2 E A';'5 1 D 9';'4 0 C 8'];
x = hex2num(q,h)
x =

    0.8750    0.3750   -0.1250   -0.6250
    0.7500    0.2500   -0.2500   -0.7500
    0.6250    0.1250   -0.3750   -0.8750
    0.5000         0   -0.5000   -1.0000
Introduced before R2006a