Taking the first bit (i.e. even vs odd)

3 次查看(过去 30 天)
Hi.
I need to read a binary data file with this information: 3600000 Samples, 8-Bits, Start Location: 112. I used the command '*uint8'.
But I have to take the first bit (i.e. even vs odd) to convert to binary 0-1 from each of the 1000 bytes. Then down sampling from 1000 to 200, by taking every 5th bit.
Can you help with that, please?

采纳的回答

Ameer Hamza
Ameer Hamza 2020-12-17
编辑:Ameer Hamza 2020-12-17
Why not take the last bit of every fifth byte, to begin with. For example, something like this
f = fopen('filename.bin', 'r');
data = fread(f, inf, '*uint8');
data_5 = data(1:5:end);
bits = rem(data_5, 2);
  2 个评论
Ameer Hamza
Ameer Hamza 2020-12-17
rem(data_5, 2) return 0 if number is even and 1 if number is odd. So it is essentially giving the least significant bit in the numbers, which is what you want according to the question.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by