MATLAB: How to convert decimal matrix matrix into binary matrix

MATLAB

hi
I want to convert 3 by 4 decimal matrix into equivalent 3 by 4 binary matrix
e.g
a=[10 9 8 7
9 7 9 6
1 2 3 8]
b=[1010 1001 1000 0111
1001 0111 1001 0110
0001 0010 0011 1000]
kindly help me I will be highly thankful to you
regards, mudasir

Best Answer

Note there's not such thing as
b=[1010 1001 1000 0111
1001 0111 1001 0110
0001 0010 0011 1000]
in matlab. Binary matrices don't exist in matlab.
The closest you can get is a cell array of string, which you'll obtain with:
a = [10 9 8 7
9 7 9 6
1 2 3 8]
b = reshape(cellstr(dec2bin(a)), size(a))
which produces:
b =
3×4 cell array
'1010' '1001' '1000' '0111'
'1001' '0111' '1001' '0110'
'0001' '0010' '0011' '1000'