Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plotting data in mathematica

  1. Jan 19, 2012 #1
    i compile a c++ program and after compiling it gives me a txt file which contains about 50000 points.
    how i can plot these points in mathematica?
  2. jcsd
  3. Jan 19, 2012 #2
    Several ways.

    1: IF your c++ program can be slightly modified to give you a file exactly like
    and you can drop that file into your Mathematica folder and call it xox.txt then


    is all you need.

    If you can't include the surrounding { and } and end each line except the next to last ending with a comma then your file won't contain a single complete Mathematica expression and you can start learning about how Mathematica does low level file reads and how to store individual lines into a list and then ListPlot the resulting list.

    If you can't drop the file into your Mathematica folder then you can start learning about the nonstandard method that Mathematica uses to give a path to your file and use that.
  4. Jan 19, 2012 #3
    i upload the data.txt file .
    how to plot it?
    i tried ListPlot but it did not work
    Last edited: Jan 19, 2012
  5. Jan 19, 2012 #4
    Attach your data.txt file and a very tiny Mathematica notebook that you are using to try to read and plot that *without any changes* to your next post here. I will look at those and try to see if there is a problem with them or whether the problem is somewhere else.

    And temporarily modify your C++ program so you don't send me 50000 points, create 50 points, verify that still doesn't work and then post the 50 point file and notebook.

    And if "but it did not work" meant you got a warning message displayed when you tried to plot then include the exact message it displayed in your post.
    Last edited: Jan 20, 2012
  6. Mar 5, 2012 #5
    Could everybody tells me how can i add a new topic ?
    Thanks a lot
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook