|
From: Daniel G. <spa...@gm...> - 2006-07-03 11:03:43
|
Hello all.
I have trouble getting gnuplot to accept binary data generated via an
external program. I wrote a C++ routine to output files in the format
specified by the gnuplot help (topic "binary"), but I always get an error
message saying "binary file read error: format unknown". Below is the piece
of code that I use to generate the files, could anybody tell me what is
wrong with it? I took a look inside the binary.c file in order to understand
where my error lies, but I think the output format should be correct (ie,
not end of line characters required). I would vastly prefer to not use
fwrite_matrix, because it generates a huge overhead in terms of files I need
to include (and find, first of all), so if anybody could have a look at this
and tell me where it fails, I would be most grateful.
(("data" is the data to be plotted, in a single dimension float array
ordered as consecutive rows))
ofstream file(currentfilename.c_str());
//first line: maxY, y0, y1, ..., y_maxY-1
file.write((char*) &fmaxY, sizeof fmaxY);
for(float f=0; f<maxY; f+=1){
file.write((char*) &f, sizeof f);
}
//all consecutive lines:
//x0, z(0,0), z(0,1), ... , z(0,maxY-1)
//x1, z(1,0), z(1,1), ... , z(1,maxY-1)
//...
for(float x=0; x < maxX; x += 1){
file.write((char*) &x, sizeof x);
for(us y=0; y < maxY; y++){
file.write((char*) &(data[y*maxX+(int)x]), sizeof
data[y*maxX+(int)x]);
}
}
file.close()
--
View this message in context: http://www.nabble.com/Trouble-with-%22binary%22-option-for-splot-tf1883880.html#a5149944
Sent from the Gnuplot - User forum at Nabble.com.
|