How can read binary file one by one?

1 view (last 30 days)
Dear ALL
I am struggling to find the solution for binary file. I want to read one by one data. Can anyone halp this point, please.
Finally I need to read 3d coordinates data.
The binary format like as follows, Thank you for advance cooperation.
Size in bytes Type Name
9 char File Type strings
4 long Version number
Variable char Last modified date
Variable char Lap time [HH:MM:SS]
Variable char Parameter
Variable char Comment
2 short Number
2 unsigned short 1~3
8 double
8 double
8 double
8 double
8 double
8 double
4 float
4 float
2 char strings
4 float
4 float
4 float
4 float
4 float
4 float
4 float
Variable char
2 unsigned short
8 double Origin(Xdata)
8 double Origin(Ydata)
8 double Origin(Zdata)
Data 16 double (double×2)
20 float Dummy data array (float×5)
20 long Dummy data array (long×5)
Variable char Dummy data array (char×5)
4 long Number of data
8 double Xdata
8 double Ydata
Data 8 double Zdata

Accepted Answer

Julian Hapke
Julian Hapke on 19 Jun 2017
have a look at the fread function
  7 Comments
Walter Roberson
Walter Roberson on 20 Jun 2017
I notice that the documentation of the format does not define the "byte order" for multi-byte variables such as unsigned short, single, or double. See https://en.wikipedia.org/wiki/Endianness for a discussion of what byte order is and why it is important.
It is common for applications designed for internet use to use "big endian", but it is common for applications designed for PC use to use "little endian". It is necessary to know the order used ahead of time.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!