Shifting data when reading from binary file using fread

조회 수: 2 (최근 30일)
Lars Janssen
Lars Janssen 2019년 5월 29일
댓글: Lars Janssen 2019년 5월 30일
I am trying to read experimental data from a binary file using fread. While the resulting data is read almost correct, the data is slightly shifting in a seemingly unpredictable manner. An example of this is given below (note that the direction of shifting is different for all signals):
fig1.png
While the result should look more like:
fig2.png
I am using the following code:
fid = fopen('sound_s3');
data = fread(fid,[1024, inf],'int32'); % reading in the 1024 signals of ~50k samples each
fclose(fid);
data = data/2^31; % converting bit to pressure
% plotting the examples
figure
plot(data(1,1:20000)');
xlabel('sample');ylabel('pressure')
figure
data = data - smoothdata(data,2,'movmean',1000);
plot(data(1,1:20000)');
xlabel('sample');ylabel('pressure')
Does anyone know what could cause this issue? I have tried basically all 'fread' options, and I am sure that the data is stored in 32 bit precision.
Note that I am sure that the signal is measured and should look like the second image.
Thanks in advance!
  댓글 수: 11
Walter Roberson
Walter Roberson 2019년 5월 30일
I got lost in the question of bit depth. One part says that the daq are single bit and then a second later it was talking about 32 bits per sample.
Lars Janssen
Lars Janssen 2019년 5월 30일
Thanks for the help anyways! I will try to look if I can further reverse engineer the files. If I find anything I will let you know.

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

답변 (0개)

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by