Filter Design Toolbox    
num2hex

Convert a number to its hexadecimal equivalent

Syntax

Description

num2hex(Hq) with no left-hand-side argument displays the quantized coefficients in quantized filter Hq as hexadecimal strings.

c = num2hex(Hq) with a left-hand-side argument c returns a cell array of quantized coefficients as hexadecimal strings. Cell array c inherits the configuration of cell array Hq.QuantizedCoefficients.

When the mode of Hq is 'float', 'double', or 'single', the coefficients are converted to IEEE Standard 754 style hexadecimal strings.

If the mode of Hq is fixed, the coefficients are converted to two's complement hexadecimal strings.

y = num2hex(q,x) converts numeric array x into hexadecimal strings returned in y. When x is a cell array, each numeric element of x is converted to hexadecimal. If x is a structure, each numeric field of x is converted to hexadecimal.

For fixed-point quantizers, the representation is two's complement. For floating-point quantizers, the representation is IEEE Standard 754 style.

For example, for q = quantizer('double')

The leading fraction bit is 1, all other fraction bits are 0. Sign bit is 1, exponent bits are all 1.

Sign bit is 0, exponent bits are all 1, all fraction bits are 0.

Sign bit is 1, exponent bits are all 1, all fraction bits are 0.

num2hex and hex2num are inverses of each other, except that num2hex returns the hexadecimal strings in a column.

Examples

This is a floating-point example using a quantizer q that has 6-bit word length and 3-bit exponent length.

Algorithm

Call the num2hex method of the coefficient's quantizer. The numeric values are quantized first by q; if you have coefficients that are exactly equal to 1, and 1 is not representable in the arithmetic format, no binary representation for 1 will exist, and 1 is quantized according to q. Beware of this when q.overflowmode = 'wrap', because 1 will be quantized to -1.

For example,

returns the hexadecimal 816 = -110.

Errors

If one or more quantized coefficients has a real or imaginary part that is exactly equal to 1, and 1 is outside the range for the quantizer, those coefficients are saturated to 1 -  (where is the epsilon of the coefficient quantizer) and the operation returns a warning message.

See Also
bin2num, hex2num, num2bin


  num2bin num2int 

Learn more about the latest releases of MathWorks products:

 © 1994-2009 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS