フィルターのクリア

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 Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by