Read data(in bytes) from text file and convert it to a vector in 8 bit format

7 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2018-8-1
reshape(output.', 1, [])
  2 个评论
Shannon Cherry
Shannon Cherry 2018-8-1
Thanks, this works partially. The output 3x7 matrix is concatenated to form a 1x21 vector, but I want the output 3x7 matrix to be converted to 3x8 matrix first so that the reshape command can produce a 1x24 vector.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by