How I can convert from binary to character?

2 ビュー (過去 30 日間)
Abduellah Elbakoush
Abduellah Elbakoush 2022 年 1 月 21 日
回答済み: Fangjun Jiang 2022 年 1 月 21 日
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 ?

採用された回答

Rik
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 = 1×11 cell array
{'00010010'} {'10100110'} {'00110110'} {'00110110'} {'11110110'} {'00000100'} {'11101010'} {'11110110'} {'01001110'} {'00110110'} {'00100110'}
data=bin2dec(data);
data=reshape(data,1,[]);
char(data)
ans = '¦66öêöN6&'

その他の回答 (1 件)

Fangjun Jiang
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)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by