Working with binary and hex data

2 vues (au cours des 30 derniers jours)
Konstantin
Konstantin le 30 Mai 2012
I have amount of HEX-words, like 4BC1 2452 62AC .....
I want to make a binary string with it. I'v found decision, but I'don like it, because it isn't Matlab-way. For example I work with 1 word
INIT='6559';
For the fist I make binary string with functions
sREG(1:N)=dec2bin(hex2dec(INIT))';
sREG is a string-type, so the next step - I convert every symbol in double
for i=1:N REG(i)=str2double(sREG(i)); end
It's very long way, so I dont like it. Is the any pre-definded functions in Matlab for solving my problem?

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 30 Mai 2012
eg
h = {'4BC1' '2452' '62AC'};
out = dec2bin(hex2dec(h))-'0';
  1 commentaire
Konstantin
Konstantin le 30 Mai 2012
Отличное решение, спасибо :-)

Connectez-vous pour commenter.

Plus de réponses (1)

bes
bes le 30 Mai 2012
  1 commentaire
Konstantin
Konstantin le 30 Mai 2012
Thank you!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by