[英]Reading binary file with Octave
I'm trying to a binary file consisting of floats with Octave (on OS X), but I'm getting the following error: 我正在尝试使用包含Octave的二进制文件(在OS X上),但是出现以下错误:
octave-3.2.3:2> load Input.dat R -binary
error: load: failed to read matrix from file `Input.dat'
The file was written like so: 该文件是这样写的:
std::ofstream fout("Input.dat", std::ios::trunc | std::ios::binary);
fout.write(reinterpret_cast<char*>(Buf), N*sizeof(double));
fout.close();
Any idea what could be going wrong here? 知道这里可能出什么问题吗?
load Input.dat R -binary
expects the file Input.dat to be in Octave's binary file format. load Input.dat R -binary
期望文件Input.dat为八度的二进制文件格式。
You need to figure out what Octave's binary format is if you want to do it like that. 如果要这样做,您需要弄清楚八度的二进制格式是什么。 However, if instead you want to output the file from C++ as you have, then you can read it in using Octave's fopen and fread functions.
但是,如果您想从C ++输出文件,则可以使用Octave的fopen和fread函数读取它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.