필터 지우기
필터 지우기

How do I specify the ranges of atan2?

조회 수: 1 (최근 30일)
Fran
Fran 2013년 4월 12일
Hello,
I would like to, based on a vector with points (0,0) and (x,y) where (x,y) is anywhere in the plane, to calculate the angle between that vector and the positive vertical Y-axis.
So, I would like that when the vector matches the positive Y, I get 0 degrees.
AND I would like that it increases when going counterclockwise. AND I would like that I have a range between 0 and 360 degrees, no minus or other values.
How to do this with atan2? I am having problems with it even though it's simple trigonometry. I'm trying to avoid using IF statements and such.
Any help would be appreciated.
Kind Regards,
Francesco

답변 (1개)

Iman Ansari
Iman Ansari 2013년 4월 12일
편집: Iman Ansari 2013년 4월 12일
I replaced x and y in atan2d:
[x,y]=meshgrid(1:-0.1:-1);
m = atan2d(x,-y)+180;
mesh(x,y,m)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by