PDA

View Full Version : Polar Coordinates


jbeckton
19 Jan 2008, 05:52pm
Hi, we did some simple excersizes with rectangular and polar coordinates and are now tasked with using matlab to do the calculations for us. This is my senior year in engineering and I haven't really used much Matlab since my freshmen year so it's a bit of a struggle. I have managed to get all of the other problem s in Matlab but am stuck with this last one. Any help would be greatly appreciated. Thanks in advance:

Perform the operation using polar coordinates, and express the result in standard rectangular form: (2+j)^2

I used the following function to convert 2+j to polar coordinates:



<DL class=codebox><DT><DD><CODE>>> [Theta_a, R_a] = cart2pol( real(2), imag(j) )

Theta_a =

0.4636


R_a =

2.2361</CODE>
</DD></DL>

So I now have the function is polar coordinates but I do not know how to square this function before converting ot back to rectangular coordinates uning this function:



<DL class=codebox><DT><DD><CODE>[x, y] = pol2cart(Theta_a, R_a);
new_a = x + y*i </CODE>
</DD></DL>

The answer should be: 5[cos(2theta) + j sin(2theta)], theta=tan^-1 (1/2)

Can anyone tell me what I need to do to square that function?

Thanks

shwaip
19 Jan 2008, 06:38pm
it's probably better to just write your own conversion, rather than use the matlab builtins. that way you can learn something.

for polar [ r e^(I theta) ] -> Cartesian (a+bI):
a=r*cos(theta);
b=r*sin(theta);

for cart -> polar:
r=sqrt((a.^2 + b.^2));
theta = atan2(b,a);

jbeckton
19 Jan 2008, 08:56pm
Thanks, that will help me get from polar to cartesian, but how do I perform the requested operation using polar coordinates?

This is what I tried and I think it is correct, can you confirm?

>> [Theta_a, R_a] = cart2pol( real(2), imag(j) )
Theta_a =
0.4636

R_a =
2.2361
>> r=2.2361
r =
2.2361
>> theta=.4636
theta =
0.4636
>> (r*exp(theta*j))^2
ans =
3.0005 + 3.9998i

beatz
21 Jan 2008, 12:40pm
Well, you could easily confirm it yourself by calcuting (2+j)^2.

(2+j)^2 = (2+j)(2+j) = (4+2j+2j-1) = (3+4j)

Rather large error in your result for my taste, however I don't know matlab that well.

jbeckton
21 Jan 2008, 02:29pm
As you can see Matlab has rounded r and theta, I was asking if anyone knew how to remedy this or if it is acceptable.

shwaip
21 Jan 2008, 05:11pm
rather than re-assigning the values to r and theta by typing them out, you can do:

r = R_a;
theta=Theta_a;