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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

John D'Errico
John D'Errico el 21 de Dic. de 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 comentarios
Abduellah Elbakoush
Abduellah Elbakoush el 21 de Dic. de 2021
thank you so much , but I want to put them into matrix such as image matrix or text matrix
Walter Roberson
Walter Roberson el 21 de Dic. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by