How can read binary file one by one?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
… … …
… … …
… … …
댓글 수: 0
채택된 답변
Julian Hapke
2017년 6월 19일
댓글 수: 7
Walter Roberson
2017년 6월 20일
At the moment we do not know how to handle the variable length strings near the beginning of the file. There are multiple ways that variable-length strings can be represented. One common method is to put a byte of binary 0 (referred to as a NUL character) after the string, in which case the string extends to just before the NUL. Another common method is to put a binary value representing the number of characters before the string; this has the advantage of being able to include NUL as part of the string, but has the disadvantage of having to know ahead of time how the count is to be represented.
Walter Roberson
2017년 6월 20일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!