# Mathematica and large data arrays

• Mathematica

## Main Question or Discussion Point

Hi,

I have imported a data set from EXCEL that is 18 columns wide and 25 rows long. Each row of data appears within it own set of brackets as expected. I am able to pull out individual elements of the array. However, I want to plot column 2 vs column 4. How might I extract those two columns of data from my imported data? Moreover, the first two rows are text that I would prefer to omit.

Data format:

{a11,a12,....a118}
{a21,a22,....a218}
.
.
.
{a251,a252,...a2518}

Any help would be appreciated. I cannot find a similar topic at the Wolfram site.

Jim

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
The Part[...] command should probably be enough for this. It has the abbreviation [[...]].
Ranges in Part are specified using ;;, so e.g.
list[[4;;10;;2]]
will give you the elements at positions {4,6,8,10}.

Here's an array the same size as your data
data = Array[a, {18, 25}];

To extract the 2nd column you can write
data[[All,2]]
or
Transpose[data][]

To extract the 2nd column with out the first element, use
data[[2;;,2]]
or
Transpose[data][[2,2;;]]

To extract the 2nd and 4th column without the first elements use
data[[2 ;;, {2, 4}]]

Then this can be plotted with ListPlot. Eg, here's some random data
data = Accumulate[RandomReal[{0, 1}, {18, 25}]];
which is plotted using
ListPlot[data[[2 ;;, {2, 4}]], Joined -> True, PlotMarkers -> Automatic]

Thanks for the input. I was able to extract the data using a variation of what you gave me. However, I cannot make it plot. I simply get a default graph from -1 to 1 on both axes and no data.

Here is what I was able to do.
In:= tmp =
Import["E:/filename.xlsx", "FormattedData"][[1, 3 ;;, {2, 4}]]

Out = {{22.7,-2.95},{22.70,-2.983}...{22.7,-3.09}}

ListPlot[tmp] gives me an empty graph. I have tried playing with DataRange with no success.

as always thanks for any assistance.

Jim

I'm not sure why you're getting an empty plot. But the small extract of the data you provided above has the x-values for all terms equal, so you'd be getting a vertical line...
(I removed the dots and plotted it to check - it works fine.)
Maybe use Joined->True option so that you can see the line...

It turns out if I remove the "FormattedData" option from the import command ListPlot works fine. Apparently, that option doesn't put the numbers in the approrpiate format.

I truncated the data to make it easier to observe. That is why it appears as a vertical line.