ascii to binary, binary to ascii

31 vues (au cours des 30 derniers jours)
osman yurdakul
osman yurdakul le 20 Mai 2011
Commenté : Walter Roberson le 18 Mai 2016
hello matlab lovers :)
x = dec2bin('enginering');
x =
1100101
1101110
1100111
1101001
1101110
1100101
1100101
1110010
1101001
1101110
1100111
y = reshape(x',1,numel(x));
y =
11001011101110110011111010011101110110010111001011110010110100111011101100111
and i will send this data from transmitter to receiver...when the receiver receives the data,it will convert y to word of engineering data and i will see word of engineering on the monitor...
that is what i mean;
how can i get back word of engineering from string of y in matlab?
pls help me...

Réponse acceptée

Matt Fig
Matt Fig le 20 Mai 2011
char(bin2dec(reshape(y,7,[]).')).'

Plus de réponses (1)

Walter Roberson
Walter Roberson le 20 Mai 2011
bin2dec(reshape(y,7,[]).')
  2 commentaires
Kayvan Ray
Kayvan Ray le 17 Mai 2016
I used that but got this Error! What's the Problem?!
Error using reshape Product of known dimensions, 7, not divisible into total number of elements, 720.
Walter Roberson
Walter Roberson le 18 Mai 2016
Your data is 8 bit wide not 7. The person who asked the question failed to specify the number of bits of output in the dec2bin() call, so it was automatically chosen as the smallest number of bits needed to represent the characters.
In short:
bin2dec(reshape(y,8,[]).')

Connectez-vous pour commenter.

Catégories

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

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by