matlab - fwrite write the numbers in reverse Byte order -
i'm writing binary values file using fwrite
function. problem when write numbers larger 1 byte, writes each byte in reverse order, examples:
fwrite(fid,3,'int32');
writes file 03 00 00 00
instead of 00 00 00 03
.
fwrite (fid,5076,'int32');
writes file d4 13 00 00
instead of 00 00 13 d4
.
how make function write bytes in correct order?
you should use machine format parameter , switch litle endian (x86 proccessor (intel amd default value suppose) big endian.
look @ http://en.wikipedia.org/wiki/endianness understand endianess mean edit :
in link give have put
fwrite(fileid, a, precision, skip, machineformat) // replace machine format 'b'
in case :
fwrite(fid,3,'int32',0,'b');
Comments
Post a Comment