Mathematica and large data arrays

In summary, you can use the Part[...] command to extract the first two columns of data from an imported data set.
  • #1
jd83605
3
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
  • #2
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]
 
  • #3
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
 
  • #4
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...
 
  • #5
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.
 
  • #6
Glad you got it sorted!
 

Related to Mathematica and large data arrays

1. How can Mathematica handle large data arrays efficiently?

Mathematica has built-in functions and algorithms that allow for efficient handling of large data arrays. These include the use of sparse arrays, which only store non-zero elements, and packed arrays, which use optimized data types to save memory. Additionally, Mathematica has parallel processing capabilities that can speed up computations on large data arrays.

2. Can Mathematica import and export large data arrays from external sources?

Yes, Mathematica has functions for importing and exporting data from a variety of external sources, including spreadsheets, databases, and text files. These functions can handle large data arrays and can also convert the data into Mathematica's native format for efficient processing.

3. What are some useful functions for manipulating large data arrays in Mathematica?

Some useful functions for working with large data arrays in Mathematica include ArrayReshape, which can reshape an array without changing its elements, and Part, which can extract specific parts of an array. The Map and Apply functions can also be helpful for applying operations to each element of a large data array.

4. How can I visualize large data arrays in Mathematica?

Mathematica has a variety of built-in functions for visualizing large data arrays, such as ListPlot and MatrixPlot. These functions can display data in various formats, including scatter plots, line graphs, and heat maps. Additionally, Mathematica has options for adjusting the size and resolution of plots to accommodate large data arrays.

5. Are there any resources for learning more about using Mathematica with large data arrays?

Yes, there are many resources available for learning about Mathematica's capabilities with large data arrays. The Wolfram Documentation Center has a section specifically dedicated to large data arrays, with tutorials, examples, and reference guides. There are also online forums and communities where users can ask questions and share tips for working with large data arrays in Mathematica.

Similar threads

  • Linear and Abstract Algebra
Replies
6
Views
929
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • Programming and Computer Science
Replies
4
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
Back
Top