Binary to ASCII Conversion

조회 수: 8 (최근 30일)
Darshan Manjunathrao Chawan
Darshan Manjunathrao Chawan 2021년 10월 9일
댓글: David Hill 2021년 10월 9일
Hi,
I have message of 1x5120 double (binary values 0 and 1). I have to convert this to ASCII. I am supposed to use below method. Can anyone let me know what is the error in the below code, Thanks.
ASCII_1 = Message(1,1:10)*(2.^[0:9])';
u = Message(1,Nsc+1:end);
wh=2.^[6:-1:0];
m=char(u(1:7)*wh');
for k=1:1:ASCII_1
m=[m char(u(7*(k-1)+1:7*k)*wh')];
end
disp(m)
Note: Message is 1x5120 double
  댓글 수: 5
Darshan Manjunathrao Chawan
Darshan Manjunathrao Chawan 2021년 10월 9일
편집: Darshan Manjunathrao Chawan 2021년 10월 9일
Okay let me keep it simple. My task was to use OFDM where the signal is given. Then I have to de-modulate, remove noise, remove Cp and etc according to ofdm block. So i did all these steps and used viterbi decoder to decode the bits and I got message in binary as 1x5120 double binary array. Now I have to convert to decimal and then get the message (Character) back. But I am not getting the end if I use below conversion.
wh=2.^[6:-1:0];
m=char(Message(1:7)*wh');
for l=2:floor(length(Message)/7),
m=[m char(Message(7*(l-1)+1:7*l)*wh')];
end
m
Message is 1x5120double binary array
David Hill
David Hill 2021년 10월 9일
You need to know how the message was transmitted for example:
a='cat in hat';
t=dec2bin(double(a),8)';%we are assuming each character is forced to be 8 bits (it is important to know)
t=t(:)'-'0';%we are assuming this is the stream you are getting, but it could be flipped depending on how it was transmitted.
If the above is the case, decoding is as simple as:
r=num2str(t);
r=char(bin2dec(reshape(r(r~=' '),8,[])'))';

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

답변 (0개)

카테고리

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