Interpreting the angle from the angle obtained by atan2 function

10 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2016-5-3
编辑:Stephen23 2016-5-3
"will its value still be in the range [-pi,pi]"
Not necessarily: (-pi) - (+pi) is not in that range.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2016-5-3
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 个评论
Luffy
Luffy 2016-5-5
Before closing this thread, one final question. If signal 1 & 2 have a phase diff phi(which is in [0,2*pi] range). I do atan2d on 1 gives me X [in -180,180 range] I do atan2d on 2 gives me Y [in -180,180 range] So X - Y could be in the range [-2*pi,2*pi]. If I do this
Angles360 = @(a) rem(360+a, 360);
phase_diff_360 = Angles2pi(X-Y);
Will the phase_diff_360 be same as phi ?
Star Strider
Star Strider 2016-5-5
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by