Finding theta in [-pi/2,pi/2] instead of [-pi/4,pi/4] using arctan

조회 수: 1 (최근 30일)
Adib Yusof
Adib Yusof 2018년 12월 31일
편집: madhan ravi 2019년 1월 2일
Hi. I need help on trigonometry.
I have a signal and a formula, which I found in a paper.
Annotation 2018-12-31 162445.jpg
I wanna find theta (as in the formula). When using function atan(), my theta ranges from [-pi/4,pi/4]. In the paper, it mentions that theta should range from [-pi/2,pi/2], and we need to take the signs of numerator and denominator of the right-hand side of the formula into consideration when calculating theta.
My question is, how do I convert from [-pi/4,pi/4] to [-pi/2,pi/2] correctly? I know if I were to convert [-pi/2,pi/2] to [-pi,pi], I just have to use atan2() function, but in this case, it's a portion of full circle.
Please help and thank you.
  댓글 수: 2
madhan ravi
madhan ravi 2018년 12월 31일
upload the code you tried
Adib Yusof
Adib Yusof 2018년 12월 31일
Hi thank you for your response.
PE_top=2*abs(H_hilb).*abs(D_hilb); %I seperate top, bottom and right to preserve signs
PE_bot=(abs(H_hilb)).^2-(abs(D_hilb)).^2;
PE_right=cos(angle(H_hilb)-angle(D_hilb));
PE_theta0=(atan((PE_top./PE_bot).*PE_right))/2;
for k=1:size(PE_top,1)
if PE_top(k)>0 && PE_bot(k)>0
PE_theta(k)=PE_theta0(k);
elseif PE_top(k)<0 && PE_bot(k)>0
PE_theta(k)=PE_theta0(k);
elseif PE_top(k)>0 && PE_bot(k)<0
PE_theta(k)=pi/2-PE_theta0(k);
elseif PE_top(k)<0 && PE_bot(k)<0
PE_theta(k)=-pi/2-PE_theta0(k);
end
end

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2018년 12월 31일
편집: madhan ravi 2019년 1월 2일
https://www.mathworks.com/help/matlab/ref/atan2.html#buct8h0-4 - it mentions "In contrast, atan(Y/X) returns results that are limited to the interval [-pi/2,pi/2], shown on the right side of the diagram."
tan(2*theta) = ((2*Ah*Ad)/(Ad^2-Ah^2))*cos(thetah-thetad);
2*theta = atan(((2*Ah*Ad)/(Ad^2-Ah^2))*cos(thetah-thetad));
theta = atan(((2*Ah*Ad)/(Ad^2-Ah^2))*cos(thetah-thetad)) / 2 % the result would be in radians

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by