Inconsistency of angle function in finding angle of vectors
Mostra commenti meno recenti
Typing the command angle(1+i) yields an angle of 45 degrees, but typing angle(-1-2i) yields -2.0344. Why is the angle being measured clockwise from the x axis in one case and and counterclockwise in the other? Is there any more consistent way to find the angle of vectors, either measured clockwise or counterclockwise?
Risposta accettata
Più risposte (1)
Typing the command angle(1+i) yields an angle of 45 degrees,
No it doesn't. It returns the equivalent angle in radians, however.
A1 = angle(1+1i)
A2 = deg2rad(45)
abs(A2-A1)
but typing angle(-1-2i) yields -2.0344.
A3 = angle(-1-2i)
Correct.
Why is the angle being measured clockwise from the x axis in one case and and counterclockwise in the other?
"theta = angle(z) returns the phase angle in the interval [-π,π] for each element of a complex array z. The angles in theta are such that z = abs(z).*exp(i*theta)."
If you want the angles to be in the interval [0, π] instead add the negative angle to 2*pi.
A3pos = 2*pi+A3
theAngles = rad2deg([A3; A3pos])
These angles are:
diff(theAngles)
360 degrees apart.
Categorie
Scopri di più su Verification, Validation, and Test in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!