Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. private static void writeToDisk(int nbins, int [] h , double low, double dx, int ntrials, double under, double over) throws IOException
  2. {
  3. String filename ="C:\\hist1.csv";
  4. FileWriter file1 = new FileWriter(filename);
  5. PrintWriter outputFile = new PrintWriter(file1);
  6.  
  7. double low; double dx; int nbins; double serror; int sum; int under; int over;
  8.  
  9. screen.println("Writing to disk, please wait....");
  10. outputFile.println("Binlow , " + low ); //0.4
  11. outputFile.println("Binint , " + dx ); //width
  12. outputFile.println("nbins , " + nbins ); //n bins
  13. outputFile.println("stat error , " + serror );
  14. outputFile.println("success trials , " + sum );
  15. outputFile.println("ntrials , " + ntrials);
  16. outputFile.println("underflow , " + under);
  17. outputFile.println("Overflow , " + over);
  18.  
  19.  
  20. for (int n = 0; n <= nbins-1; n++)
  21. {
  22. // calculate the x coordinate of the centre of each bin
  23. double binCentre = low + dx/2 + n*dx;
  24. outputFile.println( n + "," + binCentre + "," + h[n] );
  25. // note in the above line we specifically write the comma into the file
  26. }
  27. outputFile.close(); // close the output file. THIS IS AN IMPORTANT LINE
  28. screen.println(" Data written to disk in file " + filename);
  29. return;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement