How I can convert from binary to character?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Abduellah Elbakoush
il 21 Gen 2022
Risposto: Fangjun Jiang
il 21 Gen 2022
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 Commenti
Risposta accettata
Rik
il 21 Gen 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 Commenti
Più risposte (1)
Fangjun Jiang
il 21 Gen 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 Commenti
Vedere anche
Categorie
Scopri di più su Convert Image Type in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!