131072 Loading a binary file in which data is stored.

5 views (last 30 days)
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.

Answers (1)

Cris LaPierre
Cris LaPierre on 5 Jun 2025
Edited: Cris LaPierre on 5 Jun 2025
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 Comments
薫
on 9 Jun 2025
Moved: Cris LaPierre on 9 Jun 2025
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 on 9 Jun 2025
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.

Sign in to comment.

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!