How I can convert from binary to character?
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Rik
on 21 Jan 2022
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 Comments
More Answers (1)
Fangjun Jiang
on 21 Jan 2022
%%
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 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!