matlab中给出以下几种类型,供参考:
machinefmt
— Order for reading bytes'n'
(default) | 'b'
| 'l'
| 's'
| 'a'
| ...
Order for reading bytes in the file, specified as one of the strings in the table that follows. For bit
and n
ubit
precisions, n
machinefmt
specifies the order for reading bits within a byte, but the order for reading bytes remains your system byte ordering.
| Your system byte ordering (default) |
| Big-endian ordering |
| Little-endian ordering |
| Big-endian ordering, 64-bit long data type |
| Little-endian ordering, 64-bit long data type |
By default, all currently supported platforms use little-endian ordering for new files. Existing binary files can use either big-endian or little-endian ordering.
c++中对于int,和float的数据,可以用下列方法进行位置互换:
((unsigned int *)data)[i] = ntohl(((unsigned int *)data)[i]);
参考:
http://cn.mathworks.com/help/matlab/ref/fread.html#inputarg_machinefmt