views:

441

answers:

1

I have a file with 40,000 data points. In Matlab I can use the plot command to draw the plot:

aaa = Import('file Name');
plot(aaa,mesh)

How do I do it in Mathematica? I tried:

aaa = Import["File Name"]
ListPlot3D[aaa]

but it doesn't work.

+6  A: 

You have two issues here: (1) how to import the data into Mathematica and (2) how to display it.

For the first problem, the simplest answer is: it depends on the format of the data. If the file is one of the supported types, Import has a number of capabilities that can't be beat. If your data is just tab (or, whitespace) delimited, use the "Table" format, as follows:

Import["file name", "Table"]

using the various import options to specify the record and field separators. Alternatively, you can use ReadList, which simply reads in a list of values. If your data is of the form

value value value ... value
etc.

where value is numeric and each line is a separate record, I'd import it using

ReadList["file name", Number, RecordLists -> True]

which loads the file into a rectangular array.

As to the second problem, if your data is a set of triples, i.e. (x, y, z), or just a set of height values, then ListPlot3D should work just fine. If your data is instead of the form (x, y, z, f), where f is the function value at (x, y, z), then you should use ListContourPlot3D instead. You specify which contours you want by using the Contour option. Be warned, ListContourPlot3D may take a while to generate the plot depending on how large your data set is. Also, it can be a memory hog, on my machine (G4, MacOS 10.4, 2 GB) a ListContourPlot3D of an 80 x 80 x 80 grid can easily take 500 MB.

rcollyer