Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void writeToDisk(int nbins, int [] h , double low, double dx, int ntrials, double under, double over) throws IOException
- {
- String filename ="C:\\hist1.csv";
- FileWriter file1 = new FileWriter(filename);
- PrintWriter outputFile = new PrintWriter(file1);
- double low; double dx; int nbins; double serror; int sum; int under; int over;
- screen.println("Writing to disk, please wait....");
- outputFile.println("Binlow , " + low ); //0.4
- outputFile.println("Binint , " + dx ); //width
- outputFile.println("nbins , " + nbins ); //n bins
- outputFile.println("stat error , " + serror );
- outputFile.println("success trials , " + sum );
- outputFile.println("ntrials , " + ntrials);
- outputFile.println("underflow , " + under);
- outputFile.println("Overflow , " + over);
- for (int n = 0; n <= nbins-1; n++)
- {
- // calculate the x coordinate of the centre of each bin
- double binCentre = low + dx/2 + n*dx;
- outputFile.println( n + "," + binCentre + "," + h[n] );
- // note in the above line we specifically write the comma into the file
- }
- outputFile.close(); // close the output file. THIS IS AN IMPORTANT LINE
- screen.println(" Data written to disk in file " + filename);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement