Filter Design Toolbox    
num2bin

Convert a number to a binary string

Syntax

Description

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

c = num2bin(Hq) with a left-hand-side argument c returns a cell array of quantized coefficients as binary 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 binary strings.

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

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

num2bin and bin2num are inverses of one another, differing in that num2bin returns the binary strings in a column.

Examples

Algorithm

Numeric values in the input data are quantized first by quantizer q, then converted to their binary equivalents. When Hq has coefficients exactly equal to 1, or when the input data set x includes values equal to 1 and 1 is outside the quantizer's range, 1 is quantized according to the property values set for q because no binary representation for 1 exists. Beware of this behavior when q.overflowmode = 'wrap', because the value 1 in the input data or quantized filter coefficients gets converted and wrapped to -1 (1000 binary).

For example,

returns the binary 10002 = -110 because 1 lies outside the maximum value (0.8750) for q.

Errors

When one or more quantized coefficients have real or imaginary parts that equal 1, and the number format does not include 1 in its range, 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, num2hex


  noverflows num2hex 

Learn more about the latest releases of MathWorks products:

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