If z is a vector , what is the difference between angle(z) and atan2(z)
7 views (last 30 days)
Show older comments
Commented: Hassan Abdelazeem on 12 Jan 2022
If z is a vector z=x+j*y, what is the difference between angle(z) and atan2(z)
becuae when I used angle(x+i*.y) gives a differen results
this is the matlab code
t=zeros(N,1); Bmx=zeros(N,1); Bmy=zeros(N,1);
P1 = atan2(Bmy,Bmx);
You could not possibly have used atan2, becuase atan2 does not work with only one argument.
Edited: John D'Errico on 12 Jan 2022
Perhaps you did not use atan2 properly. Consider this example:
z = [1+i,1-i,-1+i,-1-i];
If you want the result in degrees, this is not difficult. In fact, with atan2d, it already does the conversion for you to degrees.
The two functions will be compatible, as long as you use them properly. remember that atan2 is a TWO argument utility. You need to separate out the real and imaginary parts to use atan2 or atan2d.
More Answers (1)
Paul on 12 Jan 2022
Edited: Paul on 12 Jan 2022
atan2() returns the answer in radians. So multiply it by 180/pi as for P2 and P3 (or use atan2d(), though atan2d() might result in small numerical differences). And P1 will also need to be multiplied by 1.6 to match P2 and P3.
Find more on Lengths and Angles in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!