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

1 view (last 30 days)
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

Accepted Answer

John D'Errico
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 Comments
Walter Roberson
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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by