MATLAB: How to get the wind speed and direction values from u and v components
"wind speed & direction"
As the quiver function shows speed and direction by arrows, there might be a built in function to get the speed and direction values.
Could anyone help please.
Best Answer
The‘u’ and‘v’ are the‘x’ and‘y’ components of the plotted vector. To get the magnitude, use thehypot function, and to get the direction, use theatan2 function. You can use these little utility functions to convert theatan2 oratan2d output to[0,p2*pi] or[0,360] representation:
Angles360 = @(a) rem(360+a, 360); % For ‘atan2d’
Angles2pi = @(a) rem(2*pi+a, 2*pi); % For ‘atan2’
These results will correspond to the mathematical convention for angle orientation, not the compass convention.
With respect to the delay, see if thefinddelay (link) function will do what you want. (I believe it was introduced inR2015b. The documentation does not say specifically.)
To find the amplitudes at a specific frequency, use thefft (link) function, and compare (subtract or divide) the amplitudes at each frequency, or only your frequency-of-interest if you are only interested in one frequency. The signals must be the same length and have the same sampling frequency for this approach to work optimally.
Best Answer