Mathematica, Table Generation & Rescaling Axes

In summary: 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,
  • #1
glamotte7
19
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
  • #2
Combining the two lists is easy:

JoinedList = Table[{time[],noise[]},{i,10}]
 
  • #3
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
 
  • #4
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}}
 
  • #5
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
 
  • #6
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.
 
  • #7
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
 

1. What is Mathematica?

Mathematica is a computational software program used for mathematical, scientific, and engineering calculations. It is widely used in research, education, and industry for its powerful capabilities in data analysis, visualization, and programming.

2. How do I generate a table in Mathematica?

To generate a table in Mathematica, you can use the Table function. For example, typing "Table[i, {i, 1, 10}]" will generate a table with values from 1 to 10. You can also specify the step size and customize the table further by adding additional parameters.

3. Can I customize the axes in a Mathematica plot?

Yes, you can customize the axes in a Mathematica plot by using the Axes, Frame, and Ticks options. These allow you to change the range, scale, labels, and appearance of the axes to better suit your data and visualization needs.

4. How do I rescale the axes in a Mathematica plot?

To rescale the axes in a Mathematica plot, you can use the ScalingFunctions option. This allows you to specify a transformation function for each axis, such as Log or Sqrt, to adjust the scale and better display your data.

5. Can Mathematica handle large datasets?

Yes, Mathematica is optimized to handle large datasets and can handle millions of data points efficiently. It also has built-in functions for data import, manipulation, and analysis, making it a powerful tool for working with large datasets.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
4K
Back
Top