Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cs-142:plot-the-results [2015/01/07 15:55] (current)
ryancha created
Line 1: Line 1:
 +=NOTE=
 +This tutorial assumes you already know how to write text to a file.  If you aren't sure, please review and understand [[FileIO]].
  
 +=Introduction=
 +We want to get our cool new hotplate data into Excel so we can graph it.  In this little tutorial, we'll use a smaller example file to show the steps.
 +=Your Code=
 +==How to Output to a .CSV file==
 +In your code, the only change you need to make is in the output file name.  Instead of "​.txt",​ use "​.csv."  ​
 +<​syntaxhighlight lang="​cpp"​ line start="​1"​ highlight="​13"​ >
 +     ​ofstream myfile ("​example.csv"​);​
 +</​syntaxhighlight>​
 +
 +As long as you are printing your output like the following, Excel will be able to open it:
 +<pre>
 +0.0,​100.0,​100.0,​100.0,​0.0,​
 +0.0,​45.1,​60.6,​66.2,​0.0,​
 +0.0,​45.1,​60.6,​66.2,​0.0,​
 +0.0,​100.0,​100.0,​100.0,​0.0,​
 +</​pre>​
 +(Yours will be much bigger. ​ The point is the *comma seperated values* arranged row by row.)
 +
 +==Finding the Output File==
 +The default location for your output file is the lab's project folder inside the workspace folder
 +
 +=Excel=
 +==Opening the file==
 +If you double click on your .CSV file, Excel should open up and show you something like this:
 +[[File:​excelInit.png|600px]]
 +
 +==The Chart==
 +Select your table of values. ​ Then click the "​Insert"​ tab and find "Other Charts"​ in the Charts group. ​ The one we want is the first one under "​Surface."​
 +[[File:​3Dsurface.png|600px]]
 +
 +==Tweak it==
 +Click "​Switch Row/​Column"​ if your view of the graph isn't very good.  Also, another color is not required, but you can change it under "Chart Styles."​
 +[[File:​Switch-Color.png|600px]]
cs-142/plot-the-results.txt ยท Last modified: 2015/01/07 15:55 by ryancha
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0