Borrar filtros
Borrar filtros

convert from hexa to binary??

51 visualizaciones (últimos 30 días)
Radwa
Radwa el 2 de Feb. de 2015
Respondida: Limabean el 8 de Dic. de 2022
I have 32 bits in hexa I want to convert it to binary without lossing accuracy? I used hex2dec and then dec2bin but the output is n't as expected. ex:
v=('981ba682 4c1bfb1a b4854720 29b71d80')
v(v == ' ') = []
v=hex2dec(v)
v=dec2bin(v)
this is the expected o/p : 10011000 00011011 10100110 10000010 01001100 00011011 11111011 00011010
10110100 10000101 01000111 00100000 00101001 10110111 00011101 10000000
but I got:
10011000000110111010011010000010010011000001101111111000000000000000000000000000000000000000000000000000000000000000000000000000

Respuestas (1)

Limabean
Limabean el 8 de Dic. de 2022
Slightly different approach:
newStr = regexprep('981ba682 4c1bfb1a b4854720 29b71d80','([A-F0-9])','${dec2bin(hex2dec($1))}','ignorecase')
newStr = '10011000110111010110100010 1001100110111111101111010 10111001000101100111100 10100110111111110110000'

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