How can read binary file one by one?

2 ビュー (過去 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 Center および File ExchangeLow-Level File I/O についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by