ascii to binary, binary to ascii

조회 수: 31 (최근 30일)
osman yurdakul
osman yurdakul 2011년 5월 20일
댓글: Walter Roberson 2016년 5월 18일
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...

채택된 답변

Matt Fig
Matt Fig 2011년 5월 20일
char(bin2dec(reshape(y,7,[]).')).'

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 20일
bin2dec(reshape(y,7,[]).')
  댓글 수: 2
Kayvan Ray
Kayvan Ray 2016년 5월 17일
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 2016년 5월 18일
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,[]).')

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by