What the binary language which MATLAB deals with it to convert text to binary ?

5 visualizzazioni (ultimi 30 giorni)
I have text and I want to convert the text to binary language
Example
The text is =(Hello world)
binary language=(00010010 10100110 00110110 00110110 11110110 00000100 11101010 11110110 01001110 00110110 00100110)

Risposta accettata

DGM
DGM il 12 Apr 2022
Start with
textchar = 'Hello world';
textbin = dec2bin(double(textchar),8)
textbin = 11×8 char array
'01001000' '01100101' '01101100' '01101100' '01101111' '00100000' '01110111' '01101111' '01110010' '01101100' '01100100'
if you want that as a logical array, then
textlogical = textbin == '1'
textlogical = 11×8 logical array
0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0 0 1 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0
if you want to change the endianness
textbin = fliplr(textbin)
textbin = 11×8 char array
'00010010' '10100110' '00110110' '00110110' '11110110' '00000100' '11101110' '11110110' '01001110' '00110110' '00100110'
and so on

Più risposte (0)

Categorie

Scopri di più su Text Data Preparation 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!

Translated by