Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 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: [mg61240] Re: [mg61231] How to reverse sign on the y's in a list of (x, y)'s?
  • From: curtis <gardyloo at mail.wsu.edu>
  • Date: Fri, 14 Oct 2005 05:53:26 -0400 (EDT)
  • References: <200510130539.BAA04564@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hey,

(**** Method 1: pattern matching ****)

data = {{0, 1}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}, {0.5, 1.5}, {0.6, 

    1.6}, {0.7, 1.7}, {0.8, 1.8}, {0.9, 1.9}, {1., 2.}}

data /. {a_, b_} -> {a, -b}

(**** Method 2: ripping apart, negating, putting back together ****)

Needs["Statistics`DataManipulation`"]

Transpose[{Column[data, 1], -Column[data, 2]}]


Of course, there are a lot of ways to do the same thing. I'm not sure
what's fastest, but either of these methods works fine for me on
moderately large arrays.

           Cheers,
                C. O.



sherifffruitfly at gmail.com 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!
>
>
>  
>

-- 
|=====
|  Curtis Osterhoudt              
|  gardyloo at mail.wsu.edu                   
|  PGP Key ID: 0x235FDED1                               
|  Please avoid sending me Word or PowerPoint attachments. 
|  http://www.gnu.org/philosophy/no-word-attachments.html 
|=====


  • 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: Re: How to reverse sign on the y's in a list of (x, y)'s?