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!