I need my angles in the [-pi:pi] range instead of [0:2*pi]?
21 ビュー (過去 30 日間)
古いコメントを表示
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
2021 年 7 月 28 日
Good point, @krishna teja, wrapToPi should work well... at least for people who have the Mapping Toolbox.
採用された回答
Walter Roberson
2014 年 1 月 13 日
R(R > pi) = R(R > pi) - 2*pi;
3 件のコメント
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
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!