Polar Coordinates

edited January 2008 in Science & Tech
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

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited January 2008
    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);
  • edited January 2008
    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
  • beatzbeatz i am a hamburger Member
    edited January 2008
    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.
  • edited January 2008
    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.
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited January 2008
    rather than re-assigning the values to r and theta by typing them out, you can do:

    r = R_a;
    theta=Theta_a;
Sign In or Register to comment.