| Filter Design Toolbox | ![]() |
Convert a two's complement binary string to a number
Syntax
y = bin2num(q,b)
Description
y = bin2num(q,b) uses the properties of quantizer q to convert binary string b to numeric array y. When b is a cell array containing binary strings, y will be a cell array of the same dimension containing numeric arrays. The fixed-point binary representation is two's complement. The floating-point binary representation is in IEEE Standard 754 style.
bin2num and num2bin are inverses of one another. Note that num2bin always returns columnwise.
Examples
Create a quantizer and an array of numeric strings. Convert the numeric strings to binary strings, then use bin2num to convert them back to numeric strings.
q=quantizer([4 3]); [a,b]=range(q); x=(b:-eps(q):a)'; b = num2bin(q,x) b = 0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000
bin2num performs the inverse operation of num2bin.
y=bin2num(q,b)
y =
0.8750
0.7500
0.6250
0.5000
0.3750
0.2500
0.1250
0
-0.1250
-0.2500
-0.3750
-0.5000
-0.6250
-0.7500
-0.8750
-1.0000
See Also
num2bin
| adaptss | ca2tf | ![]() |