/* Simple program for generating graph data. Compile: gcc -O filt.c -lm -o filt.exe Run: ./filt.exe Plot: xgraph data.dat */ #include #include #include #include int main( int argc, char *argv[] ) { FILE *outfile; double x, y; int j; outfile = fopen("data.dat","w"); fprintf(outfile,"title = Filter Responses\n"); fprintf(outfile,"title_x = Frequency (MHz)\n"); fprintf(outfile,"title_y = Sensitivity (dB)\n"); fprintf(outfile,"thickness = 1.5\n"); x = -10.5; /* Generate first response pattern. */ while (x <= 10.5) { y = 0.0; for (j=0; j < 10; j++) y = y + cos( x * (double)j * 0.3 ); y = 10.0 * log10( y * y + 0.0001 ); fprintf(outfile,"%g\t%g\n", x, y ); x = x + 0.05; } fprintf(outfile,"next\n"); /* Break line for next curve. */ fprintf(outfile,"color = blue\n"); x = -10.5; /* Generate second response pattern. */ while (x <= 10.5) { y = 0.0; for (j=0; j < 7; j++) y = y + cos( x * (double)j * 0.3 ); y = 10.0 * log10( y * y + 0.0001 ); fprintf(outfile,"%g\t%g\n", x, y ); x = x + 0.05; } fclose( outfile ); printf("Wrote output to: data.dat\n"); return 0; }