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

2 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

DGM
DGM el 12 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by