-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_test.c
More file actions
37 lines (32 loc) · 806 Bytes
/
Copy pathplot_test.c
File metadata and controls
37 lines (32 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <math.h>
int main() {
double xarray[30];
double yarray[30];
FILE *pipe_gp;
pipe_gp = popen("gnuplot --persist", "w");
// fputs("set terminal png\n", pipe_gp);
int i;
int j;
fputs("load 'startup_2ch.p'\n",pipe_gp);
//fputs("set xrange [*:*]\n",pipe_gp);
fputs("set yrange [-1:1]\n",pipe_gp);
for (j=1; j<=100; j++) {
fputs("plot '-' w boxes, '-' w boxes\n", pipe_gp);
for (i=0; i<30; ++i) {
double x = (i+4*j)/100.0;
xarray[i] = sin(x);
yarray[i] = cos(x);
fprintf(pipe_gp, "%f %f\n",i+0.25, yarray[i]);
}
fputs("e\n", pipe_gp);
for(i=0; i<30; i++) {
fprintf(pipe_gp,"%f %f\n",i+0.75, xarray[i]);
}
fputs("e\n", pipe_gp);
fflush(pipe_gp);
for (i=0;i<10000000;i++) {}
}
pclose(pipe_gp);
return 0;
}