Mathematica and large data arrays

Click For Summary

Discussion Overview

The discussion revolves around extracting specific columns from a large data array imported from Excel into Mathematica, and subsequently plotting the extracted data. The focus includes technical aspects of data manipulation and visualization within the software.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Experimental/applied

Main Points Raised

  • One participant describes their data structure and seeks assistance in extracting columns for plotting.
  • Another participant suggests using the Part command to extract specific columns and provides examples of how to do so.
  • A participant reports successfully extracting the data but encounters issues with plotting, receiving an empty graph.
  • Another participant hypothesizes that the empty plot may result from having identical x-values, suggesting the use of the Joined option for better visualization.
  • The original poster later discovers that removing the "FormattedData" option from the import command resolves the plotting issue, indicating it may have affected data formatting.
  • A final participant expresses satisfaction that the issue was resolved.

Areas of Agreement / Disagreement

Participants generally agree on the methods for data extraction, but there is some uncertainty regarding the plotting issue, which is resolved through trial and error. No consensus exists on the initial cause of the plotting problem.

Contextual Notes

The discussion highlights limitations related to data formatting during import, which can affect subsequent operations like plotting. Specific assumptions about data structure and formatting are not fully detailed.

jd83605
Messages
3
Reaction score
0
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
 
Physics 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][[2]]

To extract the 2nd column without 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[127]:= tmp =
Import["E:/filename.xlsx", "FormattedData"][[1, 3 ;;, {2, 4}]]

Out[127] = {{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.

Thanks for your input.
 
Glad you got it sorted!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K