필터 지우기
필터 지우기

Interpreting the angle from the angle obtained by atan2 function

조회 수: 8 (최근 30일)
Luffy
Luffy 2016년 5월 3일
댓글: Star Strider 2016년 5월 5일
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