Re: How to reverse sign on the y's in a list of (x, y)'s?
- To: mathgroup at smc.vnet.net
- Subject: [mg61275] Re: [mg61231] How to reverse sign on the y's in a list of (x, y)'s?
- From: ggroup at sarj.ca
- Date: Fri, 14 Oct 2005 05:54:36 -0400 (EDT)
- References: <200510130539.BAA04564@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Assuming:
dat = Table[{i,Random[]},{i,10}];
One way could be:
reversedat1 = {#[[1]],-#[[2]]}& /@ dat
Or:
reversedat2 = Transpose[ {dat[[All,1]], -dat[[All,2]]} ]
The second option is far faster...
On Thu, 13 Oct 2005 01:39:38 -0400 (EDT), sherifffruitfly wrote
> Hi all,
>
> This is really dumb, but I just don't know how to do it...
>
> 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?
>
> thanks!
- References:
- How to reverse sign on the y's in a list of (x, y)'s?
- From: sherifffruitfly@gmail.com
- How to reverse sign on the y's in a list of (x, y)'s?