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

조회 수: 1 (최근 30일)
Eliza
Eliza 2020년 12월 17일
댓글: Eliza 2020년 12월 18일
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.
Eliza
Eliza 2020년 12월 18일
Thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by