Mathematica 9 is now available
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: [mg72262] Re: Complex Numbers to list of points
  • From: "Dana DeLouis" <dana.del at gmail.com>
  • Date: Sun, 17 Dec 2006 06:20:04 -0500 (EST)

Hi.  Same idea as others, but with the use of '?.

data = {1 + 3I, 2, 1 - 3I};

data /. z_?NumericQ -> {Re[z], Im[z]}

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

-- 
HTH   :>)
Dana DeLouis
Mathematica 5.2 Windows Xp.


<planetmarshalluk at hotmail.com> wrote in message
news:elosbs$ojk$1 at smc.vnet.net...
> 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.
>


  • Prev by Date: Re: Matching Or expressions
  • Next by Date: RE: Matching Or expressions
  • Previous by thread: Re: Complex Numbers to list of points
  • Next by thread: Re: How to plot field lines ?