Skip to Main Content Skip to Search
Product Documentation

bin2num - Convert two's complement binary string to number using quantizer object

Syntax

y = bin2num(q,b)

Description

y = bin2num(q,b) uses the properties of quantizer object q to convert binary string b to numeric array y. When b is a cell array containing binary strings, y is 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 the strings in a column.

Examples

Create a quantizer object 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

hex2num | num2bin | num2hex | num2int

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

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