vendredi 23 septembre 2016

Dynamic Matrix Plot in C++ using gnuplot

I am using gnuplot in C++. I need to plot a 2D Matrix, so I write it onto the file and then plot it using.

plot("plot 'mat.txt' matrix with image");

But the file is constantly being updated, so every time I run that command in a loop, it should read from the file again and plot, which isn't happening. I tried doing this

while(1)
{
    writeToFile2();
    plot("clear");
    plot("plot 'mat.txt' matrix with image");
    plot("pause 2");
    writeToFile();
    plot("replot");
    fflush(stdout);
    plot("clear");
    plot("reread");
    plot("plot 'mat.txt' matrix with image");
    plot("pause 2");
}

writeToFile2() and writeToFile() are two functions which write two different matrices onto mat.txt. How do I make it reread from the file properly?

Aucun commentaire:

Enregistrer un commentaire