Asked by mashtine
on 23 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,

Answer by Kirby Fears
on 23 Sep 2015

Edited by Kirby Fears
on 23 Sep 2015

Accepted Answer

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);

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,

Thorsten
on 24 Sep 2015

Use

cosd(90 - deg)

sind(90 - deg)

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.

Opportunities for recent engineering grads.

Apply Today
## 7 Comments

## Kirby Fears (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/244715-add-arrows-to-surface-plot-to-represent-wind-direction#comment_311753

## mashtine (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/244715-add-arrows-to-surface-plot-to-represent-wind-direction#comment_311755

## Kirby Fears (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/244715-add-arrows-to-surface-plot-to-represent-wind-direction#comment_311758

## mashtine (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/244715-add-arrows-to-surface-plot-to-represent-wind-direction#comment_311761

## Kirby Fears (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/244715-add-arrows-to-surface-plot-to-represent-wind-direction#comment_311764

## mashtine (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/244715-add-arrows-to-surface-plot-to-represent-wind-direction#comment_311765

## Kirby Fears (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/244715-add-arrows-to-surface-plot-to-represent-wind-direction#comment_311770

Sign in to comment.