I'm controlling Gnuplot within my program for fitting and plotting; however, to get the fit parameters back, I want to use Gnuplot's print-function:
FILE *pipe = popen("gnuplot -persist", "w");
fprintf(pipe, "v(x) = va_1*x+vb_1\n");
fprintf(pipe, "fit v(x) './file' u 1:2 via va_1,vb_1 \n")
fprintf(pipe, "print va_1"); // outputs only the variable's value as a string to
// a new line in terminal, this is what I want to get
...
pclose(pipe);
I've read a lot about popen()
, fork()
and so on but the answers presented here or on other sites were either lacking a thorough explanation, not related to my problem or simply too hard to understand (I'm just beginning to program).
FYI: I'm using Linux, g++ and the usual gnome-terminal.