# How I can Convert Decimal number into binary number then to matrix binary number ?

1 view (last 30 days)
Abduellah Elbakoush on 21 Dec 2021
Commented: Stephen23 on 21 Dec 2021
e,g I have 128125
i want convert to 01 1111 0100 0111 1000
then convert to 01
11
11
01
00
01
11
10
00
Stephen23 on 21 Dec 2021
N = 128125;
B = reshape(dec2bin(N,18),2,[]).' - '0'
B = 9×2
0 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 0 1

John D'Errico on 21 Dec 2021
Easy peasey.
B = dec2bin(123125)
B = '11110000011110101'
B = [repmat('0',rem(length(B),2)),B]
B = '011110000011110101'
reshape(B,2,[])'
ans = 9×2 char array
'01' '11' '10' '00' '00' '11' '11' '01' '01'
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 21 Dec 2021
B = dec2bin(123125)
B = '11110000011110101'
B = [repmat('0',rem(length(B),2)),B]
B = '011110000011110101'
reshape(B,2,[])' - '0'
ans = 9×2
0 1 1 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by