필터 지우기
필터 지우기

I need my angles in the [-pi:pi] range instead of [0:2*pi]?

조회 수: 15 (최근 30일)
Furqan Haider
Furqan Haider 2014년 1월 13일
댓글: Walter Roberson 2021년 7월 28일
I have an angle in degrees, 225 degrees. Now degtorad(225) function gives me:
>>degtorad(225)
ans =
3.9270 radians
above 'ans' is in the range 0:2pi
I want to know the procedure that i get an answer in the range -pi:pi, as 225 degrees is also equal to -2.3562 radians
225 degree=3.9270 rad
225 degree=-2.3562 rad.
I hope I have made my point clear.
Thank you in advance.
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 7월 28일
Good point, @krishna teja, wrapToPi should work well... at least for people who have the Mapping Toolbox.

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

채택된 답변

Walter Roberson
Walter Roberson 2014년 1월 13일
R(R > pi) = R(R > pi) - 2*pi;
  댓글 수: 3
Jacob Ward
Jacob Ward 2017년 9월 6일
True, but putting it inside a while loop would take care of the multiple turns, yes?
temp = 0;
while R != temp
temp = R;
R(R > pi) = R(R > pi) - 2*pi;
end
Walter Roberson
Walter Roberson 2017년 9월 6일
R = mod(R, 2*pi);
R(R > pi) = R(R > pi) - 2*pi;

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by