Question

Is there a Matlab equivalent to Pythons's cmath.rect(r, phi) that returns the complex number x with polar coordinates r and phi without resorting to

x = r * complex(  cos(phi), sin(phi)  );

?

Was it helpful?

Solution

I think you are looking for pol2cart. But the order of the arguments is different, that is, pol2cart(phi,r) as follows:

[x,y] = pol2cart(pi/6,1)
x =
    0.8660
y =
    0.5000

If you need a complex output, you can do the following afterwards:

complex(x,y)
ans =    
   0.8660 + 0.5000i
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top