Re: Changing only Y's in a list of points: How?

• To: mathgroup at smc.vnet.net
• Subject: [mg6730] Re: [mg6665] Changing only Y's in a list of points: How?
• From: Kristina Pawlikowski <pawlikk at wl.wpafb.af.mil>
• Date: Sat, 12 Apr 1997 02:16:25 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Clumsy, but I think that this works:

pointlist={{x1,y1},{x2,y2}};

pointlist =
Partition[Flatten[Transpose[Partition[Flatten[Transpose[data]],2]+{0,.3}]],
Length[pointlist]]

==>  {{x1,0.3+y1},{x2,0.3+y2}}

>   Hopefully, the subject line says it all. If not, here's what I'm trying
>to do. Suppose I have a list of points:
>
>   pointlist = { {x1,y1}, {x2,y2}, {x3,y3}, ..., {xn,yn} };
>
>   Of course, there are numbers instead of the above symbols, but you get
>the picture. Now, suppose I'd like to "raise" or "lower" this list, in
>effect, changing all the y's by a constant, but leaving the x's alone.
>   I know this can be done easily using a procedural construct, but I'm
>wondering if there's a functional equivalent, which is hopefully more
>elegant, faster, etc.
>   At first - and here, I wasn't thinking, and am almost embarassed to
>write this - I naively tried the following:
>
>   pointlist += 0.3;
>
>   Of course, 0.3 (which could be anything, really) ends up getting added
>to *all* members of all the sublists, which is not what I wanted. I've
>spent some time looking through the Mathematica (Phone)Book, as well as a
>few other sources, but I couldn't find an obvious way of solving the
>problem using Map[], Apply[], etc., to do the trick. It's probably trivial,
>but not being raised on Lisp, functional programming is still pretty new
>for me. Any suggestions?
>
>Dave...
>
>=====
>David S. Pieczkiewicz, B. A.                    david at email.labmed.umn.edu
>Health Informatics Program                      dsp3 at minotaur.labmed.umn.edu
>Division of Health Computer Sciences            dsp3 at po.cwru.edu
>University of Minnesota, Twin Cities Campus     (612) 625-8440
>http://www.nmsr.labmed.umn.edu/~dsp3
>

```

• Prev by Date: how to include additional 'outputs' in NDSolve ?
• Next by Date: Notebook Conversion Woes
• Previous by thread: Re: Changing only Y's in a list of points: How?
• Next by thread: Re: Singular Value Decomposition