Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: List manipulation question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67203] Re: [mg67163] List manipulation question
  • From: ggroup at sarj.ca
  • Date: Sun, 11 Jun 2006 23:08:27 -0400 (EDT)
  • References: <200606110617.CAA23482@smc.vnet.net>
  • Reply-to: ggroup at sarj.ca
  • Sender: owner-wri-mathgroup at wolfram.com

Hello LectorZ,

You could try something like:

Join[
  ListConvolve[{1,-1},#[[{1,2}]]],
  ListConvolve[{1/2,0,-1/2},#],
  ListConvolve[{1,-1},#[[{-2,-1}]]]
]&@list

I would be careful though about what you intend to do with this list
though.  If you are looking at the range represented by each data
point, then your handling of the end points may be slightly wrong.  If
this is what you're doing, then you've double counted some of the
region between the end points and their nearest neighbour.

Hope that helps!

On Sunday, June 11, 2006 at 2:17 AM, Lectorz wrote:

> Dear experts,

> I need to calculate distances between the elements of the following
> list:

> list={3700, 3800, 3900, 3950, 4000, 4050, 4100, 4150, 4200, 4250, 4300,
> 4350,
> 4400, 4450, 4500, 4550, 4600, 4650}

> with the following logic:

> a) If it is the first element, then take the simple difference to the
> next (i.e. 3800 - 3700)
> b) If it is the last element, then take the simple difference to the
> second last (i.e. 4650 -4600)
> c) the difference for all elements in between shoud be calculated as
> (next - last)/2 (i.e. (3900 - 3700)/2)

> This list should come out as a result:

> result={100,100,75,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50}

> Thanks a lot for your help

> LZ




  • Prev by Date: Re: ? about Rule (rewritten)
  • Next by Date: RE: ? about Rule (rewritten)
  • Previous by thread: List manipulation question
  • Next by thread: Re: List manipulation question