Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: syntax for polar complex numbers
Date: Tue, 3 Nov 2009 17:52:02 +0000 (UTC)
Organization: Federal Energy Regulatory Commission
Lines: 46
Message-ID: <hcpqk2$bb0$1@fred.mathworks.com>
References: <hcpmeu$h1o$1@fred.mathworks.com> <hcpn1m$on9$1@fred.mathworks.com> <hcpnsf$i4n$1@fred.mathworks.com> <hcpopv$gg2$1@fred.mathworks.com> <hcpq52$b9b$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257270722 11616 172.30.248.37 (3 Nov 2009 17:52:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 17:52:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1782375
Xref: news.mathworks.com comp.soft-sys.matlab:582110


"Thomas " <loparna2000.removethis@yahoo.com> wrote in message <hcpq52$b9b$1@fred.mathworks.com>...
> "Matt " <xys@whatever.com> wrote in message <hcpopv$gg2$1@fred.mathworks.com>...
> > "Thomas " <loparna2000.removethis@yahoo.com> wrote in message <hcpnsf$i4n$1@fred.mathworks.com>...
> > > "Matt " <xys@whatever.com> wrote in message <hcpn1m$on9$1@fred.mathworks.com>...
> > > > "Thomas " <loparna2000.removethis@yahoo.com> wrote in message <hcpmeu$h1o$1@fred.mathworks.com>...
> > > > > Anyone know what the syntax is for a polar complex number?  I don't see anything about that in the help or in previous newsgroup postings.
> > > > > 
> > > > > Let's say I have a voltage with a magnitude of 1 p.u. and an angle of 0.0045 radians, and I want to input that as a complex phasor (a complex number with the same magnitude and phase angle) so that I can do some complex number computations.  How would I do that?
> > > > > 
> > > > > Obviously I can convert it to rectangular format in input it as X + Yi, but that is very inconvenient.  Is there a way to input it directly as a polar complex number?
> > > > 
> > > > 
> > > > input it to what?
> > > 
> > > Let's say I want to computer the division of the following complex numbers:
> > > 
> > > V = (1.01<0.002radians) (where "<" is my makeshift angle symbol)
> > > X = 1+3i
> > > 
> > > I acutally don't want to assign variables and such and such.  I know I could go through a long tortured procedure where I assign the magnitude and angle of V to different variables and use them to calculate the real and imaginary components of V.  
> > -------
> > 
> > I don't know why you consider this a long tortured procedure. MATLAB has functions pol2cart() and cart2pol() that essentially perform these transformations for you. If you want to carry V from your example around as a single variable, you could do so as
> > 
> > V=1.01+i*0.002
> > 
> > but remember to convert it using the following 2-line function whenever you want to do arithmetic
> > 
> > function X=phasor2cart(V)
> > 
> >   [r,c]=pol2cart(V(2),V(1));
> >    X=r+c*i;
> 
> I guess it's a matter of opinion.  I have a lot of these to do.  Would like to know simplest way.  Using cart2pol, easiest way would be the following:
> 
> [vre,vim] = cart2pol(0.465,1.01);
> (vre+i*vim)/(1+3i)
> 
> You cannot, as you suggest, simply enter V=1.01+i*0.002.  (Actually, that happens to work in this special case, since the phase angle is so small that abs(V) = Re(V) and angle(V) = Im(V), but it wouldn't work in general.)
> 
> I just thought that, given Matlab's power to do complex computations, they might have some more convenient way for specifying polar complex numbers in computations, or assigning polar complex numbers to variables.

Sorry, I meant to use pol2cart in my example, not cart2pol.  It would be:

[vre,vim] = pol2cart0.465,1.01);
(vre+i*vim)/(1+3i)