Making C code plot a graph automatically

后端 未结 5 2134
离开以前
离开以前 2020-11-30 00:49

I have written a program which writes a list of data to a \'.dat\' file with the intention of then plotting it separately using gnuplot. Is there a way of making my code pl

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 01:28

    Although I've seen a lot of ways of doing this, the most simplest way of doing this would be by using the system() (from stdlib.h) function in C. First make a gnuplot script and save it as "name.gp" (neither the name nor the extension matter).
    A simple script would be,

    plot 'Output.dat' with lines
    

    After saving this script file, just add
    system("gnuplot -p name.gp");
    at the end of your code.
    It's as simple as that.

    Make sure to add gnuplot path to the Windows System Path variables.

提交回复
热议问题