Hey guys,
i want to read a binary file which has been read with matlab with this format; 8x double in one line, varying number of lines depending on the file.
in matlab i can read it like this:
fid=fopen("filepath),'r')
initial_state = fread(fid, [8 inf],'double'); #
from the matlab documentation i found that a matlab double = 64Bits or 8Bytes
i am using a 64-bit version of qt. This is how i tried to read the file:
QFile binary
("filepath.bin");
in.
setFloatingPointPrecision(QDataStream::DoublePrecision);
//64-bit double d1,d2,d3,d4,d5,d6,d7,d8;
in >> d1 >> d2 >> d3 >> d4 >> d5 >> d6 >> d7 >>d8;
qDebug() << d1 << d2 << d3 << d4 << d5 <<d6 << d7 <<d8;
QFile binary("filepath.bin");
binary.open(QIODevice::ReadOnly);
QDataStream in(&binary);
in.setFloatingPointPrecision(QDataStream::DoublePrecision); //64-bit
double d1,d2,d3,d4,d5,d6,d7,d8;
in >> d1 >> d2 >> d3 >> d4 >> d5 >> d6 >> d7 >>d8;
qDebug() << d1 << d2 << d3 << d4 << d5 <<d6 << d7 <<d8;
To copy to clipboard, switch view to plain text mode
From qt documentation:
QDataStream & QDataStream:perator>>(double & f)
i think this is what i need but i cant figure out how to use it. The output i am getting are not the output that matlab is reading. can someone point me in the right direction? cheers!
Bookmarks