Mathematica, Table Generation & Rescaling Axes

Click For Summary

Discussion Overview

The discussion revolves around generating and manipulating data tables in Mathematica, specifically focusing on combining lists for plotting and rescaling axes for simulated data acquisition. Participants explore methods for creating a structured table from two lists and address challenges related to plotting and data processing techniques.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Exploratory

Main Points Raised

  • One participant describes generating two lists in Mathematica: one for time values and another for simulated noise data, expressing difficulty in combining these lists into a structured format for plotting.
  • Another participant suggests using the Table function to create a combined list of time and noise values, demonstrating a method to achieve this.
  • A follow-up question is raised about how to add two such tables together, specifying that the Y values should be summed while the X values should be averaged after being multiplied by 1/2.
  • Further examples are provided to illustrate how to combine lists and perform the desired operations on the data.
  • One participant seeks recommendations for performing digital signal processing tasks in Mathematica, comparing it to MATLAB's capabilities and asking for resources or packages compatible with Mathematica Student Version 8.
  • Another participant comments on the challenges of transitioning between different software tools for signal processing, noting the lack of straightforward methods for translating between them.

Areas of Agreement / Disagreement

Participants generally agree on the methods for combining lists and performing operations on them, but there is no consensus on the best approach for digital signal processing in Mathematica compared to MATLAB.

Contextual Notes

Participants express uncertainty regarding the availability of specific packages for signal processing in Mathematica and the potential frustrations of switching from MATLAB to Mathematica.

Who May Find This Useful

This discussion may be useful for users of Mathematica who are interested in data manipulation, plotting, and digital signal processing, particularly those transitioning from MATLAB.

glamotte7
Messages
19
Reaction score
0
Hi,

Have a problem: I'm generating 2 lists in Mathematica:

In: time = Table[(r - 1.0)/10.0 , {r, 10}]
Out: {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}


In: noise = Table[RandomVariate[NormalDistribution[0, 1.4], 10]]
Out: {2.16764, -1.38203, -0.395928, -0.58616, 0.714317, -1.46027, \
-0.100758, -0.162811, -1.34202, -0.612508}

First list is to set up a time axis for simulated data acquistion and second is for the simulated data (white noise centered at 0 with a stddev of 1.4).

First of all, despite lengthy attempts, I can't seem to combine the lists into a table structured like {0., 2.16},
{.1, -1.38},
{.2, -.39}, etc.
If I could do this I'd then like to do a ListPlot of the data, with the X axis stopping at 1.0 or 0.9 seconds and the noise on the Y axis.

After multiple unsuccessful attempts at this, I then ListPlotted the data and the times separately (both on the Y axis). Unfortunately my X axis always goes from 0 to 10 since 10 data points are obtained for both lists, as is expected. I thought I would be able to easily scale the termination of the X axis from 10 down to 1, since the data is obtained in 1 second. Again, despite hours of work, I can't figure out how to do this. I have Mathematica Student Version 8. This all seems like such a simple problem to solve since I'm simulating sampling data (noise) at a sampling rate of 10/sec.

I'm requesting input on both of these issues. How do you make a plotable table from 2 lists, making one list the X axis and one the Y axis? Secondly, how do you rescale data points indexed on the X axis down into a one second time period to correspond to the sampling rate?

Thanks,

glamotte7
 
Physics news on Phys.org
Combining the two lists is easy:

JoinedList = Table[{time[],noise[]},{i,10}]
 
Hi phyzguy,

That worked great!

Another related question if I may:

I wish to add 2 of these tables together to get a new table. Each table has 2 columns.

I want the 2nd columns (the Y columns) to add together in the usual way.

I want the 1st columns (the X columns) to each be multiplied by 1/2 and then added together.

How would I do that?

Thanks,

glamotte7
 
If you need to combine two lists as you describe

In[1]:= time={0.,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
noise={2.16764,-1.38203,-0.395928,-0.58616,0.714317, -1.46027,-0.100758,-0.162811,-1.34202,-0.612508};
Transpose[{time,noise}]

Out[3]= {{0.,2.16764},{0.1,-1.38203},{0.2,-0.395928}, {0.3,-0.58616},{0.4,0.714317},{0.5,-1.46027}, {0.6,-0.100758},{0.7,-0.162811},{0.8,-1.34202}, {0.9,-0.612508}}

With the first element of each pair being 0, .1, .2 ... you should see that ListPlot does use 0 to 1 for your X axis.

To add your two lists

In[4]:= v1={{1,2},{2,5},{3,7}};v2={{2,8},{3,11},{5,12}};
f[{x1_,y1_},{x2_,y2_}]:={(x1+x2)/2,y1+y2};
Thread[f[v1,v2]]

Out[7]= {{3/2, 10}, {5/2, 16}, {4, 19}}
 
Bill Simpson,

Thanks so much. Really glad to have that method in my back pocket now.

I'm just getting started with doing digital signal processing work with Mathematica. Have seen similar work done with MATLAB. I need in particular an easy method to do Fast Fourier Transforms, perform a function similar to the pwelch function in MATLAB, apply low pass filters and Butterworth filters, plot periodograms, etc.

MATLAB has a signal processing toolbox for doing these things. Do you have a recommendation on how to accomplish these things with Mma? Anything I should read to get started? Is there a package or anything else you can recommend, compatible with Mma Student Version 8 (preferably inexpensive)?

glamotte7
 
Google
Mathematica signal processing
and you will find a variety of helpful pages.

Perhaps similar to word processors, but much more extreme with math software tools, trying to switch from one to another is almost always a frustrating experience.

I recall years ago some discussion about whether it might be possible to automatically translate from one tool to another. It was soon pretty much agreed that this would be impossible for all but the simplest tasks. I'm not even aware of a large "dictionary" that would aid in manually translating from one tool to another.

If you have resources and associates who are using Matlab successfully for the sort of things you need to do then you might consider going with what those around you are using. That can sometimes dramatically reduce frustration and increase leverage.
 
Thanks Bill,

Actually the point of the work I'm doing is to redo solutions to problems using Mma that we already have the solutions for using Matlab.

glamotte7
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
5K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
10K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K