MathGroup Archive 2005

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

Search the Archive

Re: How to reverse sign on the y's in a list of (x, y)'s?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61284] Re: How to reverse sign on the y's in a list of (x, y)'s?
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Fri, 14 Oct 2005 05:55:16 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 10/13/05 at 1:39 AM, sherifffruitfly at gmail.com wrote:

>Import from excel gives me a list of ordered pairs, and I want the
>2nd element of each pair to be of opposite sign. Sticking the
>negative sign in front of the entire Import statement reverses both
>the 1st and the 2nd elements (duh). How do I get just the second
>item to reverse sign?

There are a variety of ways to do this. First, to generate some data

In[1]:=
data = Table[{Random[], Random[]}, {5}];

Using Map

In[2]:=
({First[#1], -Last[#1]} & ) /@ data
Out[2]=
{{0.9429272001031446,  -0.737894083389935}, 
  {0.3224339596386182, -0.08532310093771701}, 
  {0.25461414573678764 -0.24081290477367653}, 
  {0.38201984290511914, -0.25350600514488736}, 
  {0.7548652608303964,  -0.6396949615917464}}

Using matrix multiplication

In[3]:=
data . {{1, 0}, {0, -1}}

or using Transpose

In[4]:=
{x, y} = Transpose[data]; 
Transpose[{x, -y}]

and I am sure there are other ways I haven't thought of.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: How to reverse sign on the y's in a list of (x, y)'s?
  • Next by Date: Re: big integer for Range
  • Previous by thread: Re: How to reverse sign on the y's in a list of (x, y)'s?
  • Next by thread: Re: How to reverse sign on the y's in a list of (x, y)'s?