How can read binary file one by one?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Asaduzzaman Md
el 19 de Jun. de 2017
Comentada: Walter Roberson
el 20 de Jun. de 2017
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 comentarios
Respuesta aceptada
Julian Hapke
el 19 de Jun. de 2017
7 comentarios
Walter Roberson
el 20 de Jun. de 2017
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
el 20 de Jun. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Low-Level File I/O en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!