Converting binary characters into a char - Error!
Mostrar comentarios más antiguos
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 comentario
Aravind chockaiaah KANNAN
el 23 de Mayo de 2020
very good question but i am unable to solve this....
Respuestas (1)
Walter Roberson
el 23 de Mayo de 2020
0 votos
You have 8 bits per character, not 7 bits per character. 255 characters of 8 bits each = 2040 bits.
5 comentarios
Aravind chockaiaah KANNAN
el 23 de Mayo de 2020
what shoud he change here?
Sanjay Ravichandran
el 23 de Mayo de 2020
Walter Roberson
el 23 de Mayo de 2020
n = 8;
stream_n = reshape(msg_error_checked',n,[])';
info_stream = stream_n(:,1:k);
question = dec2bin(char(info_stream.' + '0'));
Walter Roberson
el 23 de Mayo de 2020
How many characters are you expecting?
Why did you use 7 bits per character instead of 8?
Sanjay Ravichandran
el 23 de Mayo de 2020
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!