How to convert decimal matrix matrix into binary matrix?
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Andriy Kavetsky
el 23 de Oct. de 2016
0 votos
Use dec2base(a,2) command to get string array of binary numbers and str2num(dec2base(a,2)) to convert string into numbers
3 comentarios
Mudasir Ahmed
el 23 de Oct. de 2016
Walter Roberson
el 23 de Oct. de 2016
a=[10 9 8 7
9 7 9 6
1 2 3 8];
dec2base(a)
gives a char array as output.
To convert back you need to use base2dec()
Mudasir Ahmed
el 25 de Oct. de 2016
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!