Read data(in bytes) from text file and convert it to a vector in 8 bit format
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Shannon Cherry
le 1 Août 2018
Commenté : Walter Roberson
le 1 Août 2018
I have a text file with byte data (example: 36 90 75 ...). Now I want to read this text file and convert it to a 8 bit vector. I'm using the below code to do the same.
input = textread('byteData.txt');
output = de2bi(input);
output from my code:
0 0 1 0 0 1 0
0 1 0 1 1 0 1
1 1 0 1 0 0 1
Expected output: I do not need the output in matrix format, but I need them as a vector and in 8 bit format as shown below.
0 0 0 1 0 0 1 0 0 0 1 0 1 1 0 1 0 1 1 0 1 0 0 1
0 commentaires
Réponse acceptée
Walter Roberson
le 1 Août 2018
reshape(output.', 1, [])
2 commentaires
Walter Roberson
le 1 Août 2018
No you don't. What you want is
output = de2bi(input, 8);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!