필터 지우기
필터 지우기

How can read binary file one by one?

조회 수: 3 (최근 30일)
Asaduzzaman Md
Asaduzzaman Md 2017년 6월 19일
댓글: Walter Roberson 2017년 6월 20일
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

채택된 답변

Julian Hapke
Julian Hapke 2017년 6월 19일
have a look at the fread function
  댓글 수: 7
Walter Roberson
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
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 CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by