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.

  • $\begingroup$ I believe you mean $2e^{i \frac{\pi}{6}}$ $\endgroup$ – Ahmad Bazzi Jul 20 '18 at 15:35
  • $\begingroup$ No, @AhmadBazzi it's -2 $\endgroup$ – Yatish Jul 20 '18 at 15:36
  • $\begingroup$ 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}$? $\endgroup$ – celtschk Jul 20 '18 at 15:40
  • $\begingroup$ @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. $\endgroup$ – Yatish Jul 20 '18 at 15:45
  • $\begingroup$ @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. $\endgroup$ – 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.

  • $\begingroup$ But, what if I want to retrieve the number the way I had entered it? I want the minus sign with 2 instead of being converted to exp(ipi) or exp(-ipi). $\endgroup$ – Yatish Jul 20 '18 at 15:52
  • $\begingroup$ In which quadrants do you get the wrong answer? How can you detect that? How can you fix it once you detect it? $\endgroup$ – steven gregory Jul 21 '18 at 0:47
  • $\begingroup$ the angle entered in the phase part always lies between -pi and pi. Actually, it doesn't matter in which quadrant does the angle lie in the first place. If matlab finds a negative sign attached with the amplitude, the final angle is going to differ from the entered value by +pi or -pi in order to keep the amplitude positive. $\endgroup$ – Yatish Jul 21 '18 at 13:40
  • $\begingroup$ @Yatish - Hint. $e^{i\pi}=-1$, so $re^{i\theta} = -re^{i(\pi + \theta)}$ $\endgroup$ – steven gregory Jul 21 '18 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.