Matrix of bits into ASCII string

6 vues (au cours des 30 derniers jours)
Jan
Jan le 11 Avr 2014
Hi. I have a problem. I have matrix of bits ([0 1 1 1 0 1 1 1 ...], every column is 1 bit) where every 8 bits are one char. I need to convert matrix into ASCII string. How can i do that?
  2 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 11 Avr 2014
What is the result if
a=[ 1 0 0 1 0 1 0 1 1 0 0 0 1 1 1 1]
Jan
Jan le 11 Avr 2014
I used
dec2bin(word,8)
so the first bit of group of eight is always 0. In fact i could use only 7 bits... OK so how can i convert matrix into ASCII string where every 7 bits are one char?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 11 Avr 2014
char(bin2dec(reshape(char('0' + YourVector),BitsPerCharacter,[]).'))
  1 commentaire
Jan
Jan le 11 Avr 2014
Thx a lot!

Connectez-vous pour commenter.

Plus de réponses (1)

Hacene AYADI
Hacene AYADI le 15 Mar 2018
@Walter Roberson plz i have matrix of binary and i want to convert to char my matrix of 64bis and size(2,94) i need help and thx

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by