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: Complex Numbers to list of points

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72216] Re: Complex Numbers to list of points
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 14 Dec 2006 05:52:32 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <elosbs$ojk$1@smc.vnet.net>

planetmarshalluk at hotmail.com wrote:
> Hi there,
> 
> I have a list of mixed complex and real numbers returned from a function, e=
> g
> 
> {1+3i, 2, 1-3i}
> 
> I wish to convert the list to a list of points.
> 
> {1+3i,2,1-3i} /. z_Complex->{Re[z],Im[z]}
> 
> gives
> 
> {{1,3},2,{1,-3}}
> 
> Which is almost what I want, but has not dealt with the possibility of non-=
> complex numbers in the list. Is there a compact way of doing this, such wit=
> h a list of rules? Nothing obvious seems to work, the only success I have h=
> ad is splitting the list into real and complex sublists, applying rules to =
> each list individually and then recombining them, which seems like an awful=
>  lot of hard work.
> 
> What I want is
> toPoints[{1+3i, 2, 1-3i}] == {{1,3},{2,0},{1,-3}}
> 
> Any help appreciated,
> Thanks.
> 
> Andrew.
> 

The following expression should do the trick:

Rationalize[{1 + 3*I, 2, 1 - 3*I} /. x_Integer -> Complex[x, 0.0] /. 
z_Complex -> {Re[z], Im[z]}]

--> {{1, 3}, {2, 0}, {1, -3}}

Regards,
Jean-Marc


  • Prev by Date: Re: Deformed Matrix Product
  • Next by Date: RE: How to use the max value from the solution of NDSolve ?
  • Previous by thread: Re: Complex Numbers to list of points
  • Next by thread: Re: Complex Numbers to list of points