MATLAB: How to plot wind direction timeseries with arrows

arrowsplotquiverwind direction

Hi,
I would like to plot a timeseries of wind direction. I would like represent the direction at each point in time with an arrow. The direction of the wind is expressed in degrees. I have saw that quivers might do what I want with some tricks but I was wondering if there was a more specific function.
Thanks in advance,
Giacomo

Best Answer

The quiver() function is what you want to use. It's desiged exactly for this purpose.
Since your vectors are in degrees and the quiver function requires the x,y component vectors, use pol2cart() to convert your polar vectors to cartesian vectors. You'll also need to convert deg-->rad for the pol2cart inputs.
% WindDirection is the direction of wind (deg)
% WindSpeed is the magnitude of the wind vector
[xWind, yWind] = pol2cart((pi/180).*WindDirection), WindSpeed);
quiver(x, y, xWind, yWind)