Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'moving elements' topicStudent Support Forum > General > "moving elements"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
03/22/13 00:38am

Without example data showing exactly what you want this to do it is somewhat difficult to guess what the answer should be.

Suppose your data looks like this

In[1]:= v={{0,9,1,7},{7,8,9,7},{9,0,7,6},{5,8,6,8},{9,1,3,3},{2,0,3,6}};

Since I am guessing you want to look at pairs of these 4 element lists I will use Partition to group this into overlapping pairs

In[2]:= vp=Partition[v,2,1]

Out[2]= {{{0,9,1,7},{7,8,9,7}},
{{7,8,9,7},{9,0,7,6}},
{{9,0,7,6},{5,8,6,8}},
{{5,8,6,8},{9,1,3,3}},
{{9,1,3,3},{2,0,3,6}}}

Now I will define a function that is given a pair of 4 element lists in another list and will calculate something using the individual items.

In[3]:= f[{{a_,b_,c_,d_},{e_,f_,g_,h_}}]:=d<e;

And I will then use that function on all those pairs.

In[4]:= Map[f,vp]

Out[4]= {False,True,False,True,False}

Does this have anything to do with what you really want to accomplish? Or can you see how to adapt part of this to what you need.

If not then post a nice sample data set with just enough elements and with your hand calculated result of what the answer should be. Include enough data and enough different kinds of data that you are positive that someone on the other side of the country or the other side of the world and who knows nothing about what you have been working on for hours or weeks and cannot see what is in your assignment or on your screen, but will still be almost certain to easily understand and provide you with a simple solution to your problem.

URL: ,

Subject (listing for 'moving elements')
Author Date Posted
moving elements augustus 03/21/13 2:10pm
Re: moving elements Bill Simpson 03/22/13 00:38am
Re: Re: moving elements augustus 03/23/13 1:37pm
Re: Re: Re: moving elements Bill Simpson 03/23/13 2:06pm
Re: Re: Re: Re: moving elements augustus 03/25/13 10:26am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic