131072 Loading a binary file in which data is stored.

조회 수: 5 (최근 30일)
薫
2025년 6월 5일
댓글: Cris LaPierre 2025년 6월 9일
I saved 131072 data in a binary file in LabVIEW.
The data was saved in 16 bit, so the file size is 262 kB.
The sine wave data was saved and the file contains numbers between 0 and 2.3. I tried to make my own program, but I could not check the values between 0 and 2.3.
I would appreciate any advice you can give me.

답변 (1개)

Cris LaPierre
Cris LaPierre 2025년 6월 5일
편집: Cris LaPierre 2025년 6월 5일
Not sure what settings you used to record the data, but I only see values of 0, 1 and 2. If you are using an analog-to-digital converter, the quantization step size appears to be limiting what values can be captured.
Here's the code I uesd to read your file. I also plotted the first 1000 points.
% Specify the filename
unzip('Binary_000.zip');
filename = 'Binary_000.bin';
% Open the binary file for reading
fileID = fopen(filename, 'rb','ieee-be');
% We know the number of points, so use this to figure out the size of the
% header. Then skip the header
fseek(fileID,0,1);
p = ftell(fileID);
sk = p - 2*131072
sk = 24
fseek(fileID,sk,-1);
% Read the data as 16-bit floating point numbers
data = fread(fileID, 'int16',0 );
% Close the file
fclose(fileID);
plot(data(1:1000))
  댓글 수: 2
薫
2025년 6월 9일
이동: Cris LaPierre 2025년 6월 9일
Thank you for your reply.
I am using an AD converter to get the data.
I am using the “convert to word integer” function in LabVIEW.
We believe that this results in the display of only 0,1,2 numbers with no decimal point.
Correct the LabVIEW program.
Thanks for the advice.
Cris LaPierre
Cris LaPierre 2025년 6월 9일
The "To Word integer" function in LabView converts a number to a 16-bit signed integer. So yes, this explains why the file only contains integer values.

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

카테고리

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

태그

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by