Splitting Wind direction into four quadrants

Hello,
I had u & V component of wind. I converted them to wind speed & direction, using
wind_speed=sqrt((u^2)+(v^2));
wind_direction=180 + atand(u/v);
The problem is wind direction is not splitting into quadrants. As done here http://wx.gmu.edu/dev/clim301/lectures/wind/wind-uv.html

 채택된 답변

Chad Greene
Chad Greene 2016년 1월 15일

0 개 추천

I think Kelly is partly correct. You'll need the four-quadrant version of atand, which is called atan2d.
Another quick tip: Instead of this:
wind_speed=sqrt((u^2)+(v^2));
you can use
wind_speed=hypot(u,v);
which is less prone to typos.

댓글 수: 1

Student new
Student new 2016년 1월 15일
편집: Student new 2016년 1월 15일
Thanks alot Star Strider, you made my day..
You are right i was doing a mistake of (/). But i can not see comment of Star strider now..

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

추가 답변 (1개)

Kelly Kearney
Kelly Kearney 2016년 1월 15일

1 개 추천

As mentioned in those lecture notes, you'll need to use atan2 instead of atan (not atand either... your inputs aren't in degrees!) to get the four-quadrant result you want.

댓글 수: 3

Student new
Student new 2016년 1월 15일
I used v=180 + atand(u/v); and the result is fine for positive values of v.
If appear negative value of v then this formula fails
Right, never mind on the degrees comment. I was mistakenly reversing inputs and outputs in my head. But as Chad answered, you still need the atan2d variant.
Student new
Student new 2016년 1월 15일
Thanks alot Kelly Kearney

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

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2016년 1월 15일

댓글:

2016년 1월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by