As pointed out by other answers, the DEC2BIN function is one of the options you should solve this problem. However, as this other SO question noted, this can be a very slow option when converting a large number of values.
For a faster solution, you can instead use the BITGET function as follows:
a = [1 2 3 4]; %
The result of c will be an array of zeros and ones. If you want to turn this into a character string, you can use the CHAR function as follows:
c = char(c+48);
source share