Converting binary characters into a char - Error!

조회 수: 3 (최근 30일)
Sanjay Ravichandran
Sanjay Ravichandran 2020년 5월 23일
댓글: Sanjay Ravichandran 2020년 5월 23일
Hey, I have to convert a binary character into a char and I keep ending with an error.
This is not the entire code where I am trying to find the error in a message.
%% Converting the binary stream into character string
k= 4;
n = 7;
stream_n = reshape(msg_error_checked',n,[])';
info_stream = stream_n(:,1:k);
msg_stream = reshape(info_stream',1,[]);
% question = bit2char(msg_stream)
% I tried using bit2char too but it doesn't work.
question = '' ;
bin = msg_stream(1:7:length(msg_stream)-8);
question = strcat( question,char(bi2de(bin,'left-msb')));
Error I get:
This is just a part from my entire code. I can post the entire code if necessary.
Thank you in advance.
  댓글 수: 1
Aravind chockaiaah KANNAN
Aravind chockaiaah KANNAN 2020년 5월 23일
very good question but i am unable to solve this....

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

답변 (1개)

Walter Roberson
Walter Roberson 2020년 5월 23일
You have 8 bits per character, not 7 bits per character. 255 characters of 8 bits each = 2040 bits.
  댓글 수: 5
Walter Roberson
Walter Roberson 2020년 5월 23일
How many characters are you expecting?
Why did you use 7 bits per character instead of 8?
Sanjay Ravichandran
Sanjay Ravichandran 2020년 5월 23일
I can't determine the number of characters, but at the end after coding it right. I am supposed to get a sentence like 'Welcome to Matlab'. (or maybe something else).
You can check this link for the codes:
I am supposed to use 4 parity matrices among which one has the sentence.
With k being the identity matrix.
I had to eliminate the following values for k and n
1) 2 and 5
2) 3 and 6
3) 4 and 8
as I didn't get any sentence from them.
But when I use k as 4 and n as 7, I should be getting the output as its the last one left.
But, when I use the same code, it shows an error which I posted in the question section.

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

카테고리

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