Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica, Table Generation & Rescaling Axes

  1. Aug 4, 2012 #1
    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
     
  2. jcsd
  3. Aug 4, 2012 #2

    phyzguy

    User Avatar
    Science Advisor

    Combining the two lists is easy:

    JoinedList = Table[{time[],noise[]},{i,10}]
     
  4. Aug 4, 2012 #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
     
  5. Aug 4, 2012 #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}}
     
  6. Aug 5, 2012 #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
     
  7. Aug 6, 2012 #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.
     
  8. Aug 7, 2012 #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
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica, Table Generation & Rescaling Axes
  1. Mathematica: Tables (Replies: 2)

Loading...