How I can convert from binary to character?
2 次查看(过去 30 天)
显示 更早的评论
I have a binary matrix (1*88)double
e.g
0 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 0 0 0 1 0 0 1 1 0
I want to put all 8 bits together
e.g
00010010 10100110 00110110 00110110 1111 0110 00000100 11101010 11110110 01001110 00110110 00100110
then I want to convert them into letters
e.g
Hello World
Can You help me to slove this problem ?
0 个评论
采纳的回答
Rik
2022-1-21
Your binary data seems to require some modification before it contains what you expect.
data=[0 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 0 0 0 1 0 0 1 1 0];
data=char(data+'0');
data=mat2cell(data,1,8*ones(numel(data)/8,1))
data=bin2dec(data);
data=reshape(data,1,[]);
char(data)
0 个评论
更多回答(1 个)
Fangjun Jiang
2022-1-21
%%
a=[0 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0];
b=sprintf('%d',a)
c=reshape(b,[],8)
d=bin2dec(c)
e=char(d)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!