MATLAB Answers

Add arrows to surface plot to represent wind direction

34 views (last 30 days)
mashtine on 23 Sep 2015
Commented: mashtine on 24 Sep 2015
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,


Show 4 older comments
Kirby Fears
Kirby Fears on 23 Sep 2015
The "x" component is typically denoted as u and the "y" component as v. In the link you posted, it's the other way around. Moreover, there's no reason to add 180 at the end. The NCL website seems to be counting degrees in some nonstandard way. In trigonometry you start counting from 0 degrees (in the (1,0) direction) and proceed counter-clockwise around the unit circle. To fix your earlier calculation:
>> r2d = 45.0/atan(1.0);
>> atan2(sind(100),cosd(100))*r2d
ans =
When it comes to using Matlab functions, I think you'll find the Mathworks documentation more helpful than the NCL website.
If this answers your question, please remember to "Accept" my answer so the issue is closed.
mashtine on 23 Sep 2015
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,
ans =
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 on 23 Sep 2015
-179 is the correct answer.
The NCL website adds 180 to this, which would be
-179+180=1, which is incorrect.

Sign in to comment.

Accepted Answer

Kirby Fears
Kirby Fears on 23 Sep 2015
Edited: Kirby Fears on 23 Sep 2015
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.
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
% you can multiply u and v by magnitude of required


Show 2 older comments
mashtine on 24 Sep 2015
Yes that makes sense and I gather the difference between the unit circle and the convention used in meteorological terms. Sorry if my explanation was off but I thought you understood this was my intended output. So given that I have map degrees, is there a way to get u and v components that will get that meteorological map degree? I believe this to be my last question!
Thank you for bearing with me Kirby,
mashtine on 24 Sep 2015
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.

Sign in to comment.

More Answers (0)

Sign in to answer this question.