Add arrows to surface plot to represent wind direction

조회 수: 16 (최근 30일)
mashtine
mashtine 2015년 9월 23일
댓글: mashtine 2015년 9월 24일
Hi there,
I am seeing a lot of information about the quiverm function but I only have my wind direction data in degrees and not in the u and v components. Is there a simple way to project a matrix of wind direction values (360 degrees) onto a sufacem plot? Perhaps there is a way to add and arrow and align it based on the wind direction value? I do not want to add magnitude as well, just direction.
Many thanks,
  댓글 수: 7
mashtine
mashtine 2015년 9월 23일
Hi Kirby,
I believe the NCL website is giving the correct data as it will produce the correct wind direction for the negative quadrants. I am also getting the expect wind direction (easterly winds). For instance,
atan2(sind(181),cosd(181))*r2d
ans =
-179
where I should not be getting a negative direction but degrees in 0 to 360. I believe it is accounting for matlab use of the atan2 function as this differs in some software
Kirby Fears
Kirby Fears 2015년 9월 23일
-179 is the correct answer.
-179+360=181
The NCL website adds 180 to this, which would be
-179+180=1, which is incorrect.

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

채택된 답변

Kirby Fears
Kirby Fears 2015년 9월 23일
편집: Kirby Fears 2015년 9월 23일
I'm posting an example as described in my earlier comment.
Code below creates a 10x10 grid of arrows that are all pointing at 120 degrees.
x=repmat(1:10,10,1);
y=x';
deg=120; % all points have same direction
% if you have a degree array the same size as x,
% you can use cosd and sind on "deg" without
% using repmat after
u=repmat(cosd(deg),size(x));
v=repmat(sind(deg),size(x));
% you can multiply u and v by magnitude of required
quiver(x,y,u,v);
  댓글 수: 5
Thorsten
Thorsten 2015년 9월 24일
Use
cosd(90 - deg)
sind(90 - deg)
mashtine
mashtine 2015년 9월 24일
Thanks a lot Thorsten! As the I would like the arrows to point to where the wind is going to, I will use
cosd(270 - deg)
sind(270 - deg)
That seems to be working well for all degrees.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by