Interpreting the angle from the angle obtained by atan2 function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have two signals(x,y) whose absolute phases i'm calculating by using the atan2 function.Then subtracting both i'm getting the relative phase between two signals.
Because the absolute phase is calculated by atan2,it's range is [-pi,pi]. Now the relative phasei got after subtracting the absolute phase, will its value still be in the range [-pi,pi] ? How do i convert this to [0,2pi] ?
My efforts:- On the final relative phase obtained by atan2.i'm doing this
if phase >= 0 then
phase = 360 - phase;
else
phase = abs(phase);
end
This is yielding good results & matching with the phase between signals x & y, except in the range from [0 to 10] & [350 to 360]
1 commentaire
Réponses (1)
Star Strider
le 3 Mai 2016
This has worked for me when I needed to use it:
D = load('Luffy matlab.mat');
Angles2pi = @(a) rem(2*pi+a, 2*pi);
X = D.X;
Y = D.Y;
X_2pi = Angles2pi(X);
Y_2pi = Angles2pi(Y);
If you want the angles in degrees, use the atan2d function instead, and then substitute this version of the conversion anonymous function:
Angles360 = @(a) rem(360+a, 360);
4 commentaires
Star Strider
le 5 Mai 2016
My ‘Angles...’ functions don’t do radian-to-degree or degree-to-radian conversions, so this will not result in a degree result:
phase_diff_360 = Angles2pi(X-Y);
The result will be in radians if the angles are in radians.
Also, because rem and mod are nonlinear, these two are not equivalent:
Dif1 = Angles2pi(X) - Angles2pi(Y);
Dif2 = Angles2pi(X-Y);
The ‘Dif1’ assignment is mathematically correct for the angle differences. The ‘Dif2’ assignment is not correct. Again, the arguments would have to be in radian measure to use ‘Angles2p’ correctly.
Please only use radian arguments with ‘Angles2pi’, and only use degree arguments with ‘Angles360’. If you mix them, the results will be meaningless.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!