Advertisement
Guest User

Save data for gnuplot

a guest
Oct 14th, 2011
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(int argc,char** argv){
  4.  
  5.     //Open File
  6.     FILE* f = fopen("plotdata","w");
  7.     if(!f){return -1;}
  8.  
  9.     //Write Graph1
  10.     for(double x=0;x<=10;x+=1){
  11.         double y = x*x;
  12.         fprintf(f,"%lf %lf \n",x,y);
  13.     }
  14.  
  15.     //Separate data-block by 2 new lines
  16.     fprintf(f,"\n\n");
  17.  
  18.     //Write Graph2
  19.     for(double x=0;x<=10;x+=1){
  20.         double y = x*x*x;
  21.         fprintf(f,"%lf %lf \n",x,y);
  22.     }
  23.  
  24.     //Close File
  25.     fclose(f);
  26. }  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement