MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Plotting from a file

  • To: mathgroup at
  • Subject: [mg33141] Re: [mg33108] Plotting from a file
  • From: Timothy Stiles <tastiles at>
  • Date: Tue, 5 Mar 2002 03:08:46 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at

I think your first problem is addressed in the following FAQ

which describes how to set up Mathematica 4.0 to accept the exponential notation
with Import. I often use a completely different method namely

data = ReadList["datafile.dat", Number, RecordLists->True];

which is left over from the pre version 4.0 days which didn't have an Import[]

To suppress output in Mathematica end a command with a semicolon (as in the above
command). This will keep Mathematica from printing the entire file.

Finally, to plot your data, you have to use Mathematica syntax not Matlab. To plot
a list, you need to use the ListPlot[] command (Plot[] plots function directly).
The argument of ListPlot[] can be in any of several forms, a single list will be
treated as y-values with x-values assumed to be the list {1, 2, 3, ..., n}. You
can specify the y and x-values by using a list of {x, y} pairs like ListPlot[{{x1,
y1}, {x2, y2}, ... {xn, yn}}].  Hope this helps.

Tim Stiles

SuneF wrote:

> Hi
> I have this output file of floating point data from a C program.
> It is all printed in 1.435664334e-013 notation, 7 columns in total.
> When I import with:
> data=Import["datafile.dat","Table"]
> it doesn't understand the exponential notation.
> It's printing the whole file (huge file by the way) below the command and
> only a handfull of the floats seem to be understood correctly as 1.333^10-13.
> If I print the numbers as 0.00000001234 then mathematica understands,
> but this is not ideal, obviously.
> Also, later when it works I need to plot the columns, something like
> Plot[data(2,*)]
> you know, plot the second column.
> The code doesn't work, mathematica doesn't take arrays like that, not sure why.
> I'm very confused about why mathematica have both lists, arrays and matrices,
> I don't know what to work with in this case.
> Is it possible to declare a datatype like in C++ ?
> I like to know what I'm working with, call it force of habbit ;)
> Thanks,
> Sune.

  • Prev by Date: How to transform x axis on ListPlot?
  • Next by Date: Re: creating functions with variable number of options
  • Previous by thread: Plotting from a file
  • Next by thread: Re: Plotting from a file