DEC2BIN Convert Decimal to Binary String

Section: Array Generation and Manipulations

USAGE

Converts an integer to a binary string. The syntax for its use is
   y = dec2bin(x,n)

where x is the positive integer, and n is the number of bits to use in the representation. Alternately, if you leave n unspecified,

   y = dec2bin(x)

the minimum number of bits needed to represent x are used. If x is a vector, then the resulting y is a character matrix.

Example

Here we convert some numbers to bits
--> dec2bin(56)
ans = 
  <string>  - size: [1 6]
 111000
--> dec2bin(1039456)
ans = 
  <string>  - size: [1 20]
 11111101110001100000
--> dec2bin([63,73,32],5)
ans = 
  <string>  - size: [3 5]
 11111
 01001
 00000