# How can I retrieve the original phase of this complex number in matlab?

Suppose I enter a complex number, say $$z = -2e^{i\pi/6}$$

And, I have to get the phase of "z" as $[\pi/6]$ only. But when I try to retrieve the phase using 'angle(z)' in matlab, it would display the phase as $[(\pi/6)-\pi]$. I understand the reason behind shift of angle "$\pi$" and I don't want this to happen in my original phase. Please help me out on this problem.

• I believe you mean $2e^{i \frac{\pi}{6}}$ – Ahmad Bazzi Jul 20 '18 at 15:35
• No, @AhmadBazzi it's -2 – Yatish Jul 20 '18 at 15:36
• How is Matlab supposed to figure out from the number $(-\sqrt{3}-i)$ that you originally specified it as $-2e^{i\pi/6}$ and not as $2e^{i\pi/6-\pi}$ or as $2e^{i\pi/6+\pi}$? – celtschk Jul 20 '18 at 15:40
• @celtschk I get your point. What I want is- if I enter negative amplitude, it should store it as negative. On the contrary, matlab converts -1 to exp(ipi) or exp(-ipi). And, I don't want this. – Yatish Jul 20 '18 at 15:45
• @Yatish: If you need that extra information, you need to store it extra. Because in the number, there's no "space" to store it. Maybe you can store the square root of the number instead; then you can use the fact that a number has two square roots with opposite signs to store the extra sign information. – celtschk Jul 20 '18 at 15:53

The correct polar form representation of a complex number is $z = re^{i\theta}$ where $r > 0$. Matlab, correctly, interpreted $-2e^{i \frac{\pi}{6}}$ as $2e^{i \frac{-5\pi}{6}}$. If you want to use a nonstandard phase shift, then add $\pi$ to any negative phase shifts.
• @Yatish - Hint. $e^{i\pi}=-1$, so $re^{i\theta} = -re^{i(\pi + \theta)}$ – steven gregory Jul 21 '18 at 14:51