# Calculating u and v components from wind direction and speed

233 vues (au cours des 30 derniers jours)
Shai Katz le 19 Avr 2022
Hi,
I would like to plot a wind filed on a map.
I have lat vector, lon vector, wind speed vector and wind direction vector.
As far as I understand the simplest way is to use quiverm or quiver (but quiver can't plot over a map).
To use both function I need the u and v components, and I don't have them, and I don't have the angle for the cos and sin functions in these formulas.
How can calculate them? converting wind direction to math degrees (in a formula) isn't straight forward.
Appricate your help for the easiest way.
Thank you!
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Les Beckham le 19 Avr 2022
Modifié(e) : Les Beckham le 19 Avr 2022
Actually, it is straightforward.
v (North (y) component) and u (East (x) component) can be calculated from S (wind speed) and D (direction) as follows
S = 10; % example - replace with your data
D = 30; % example, wind coming from the North-northeast
D = 270 - D; % convert wind direction to Matlab graphics coordinate convention
u = S*cosd(D);
v = S*sind(D);
quiver(0,0,u,v)
axis equal
xlim([-10 10])
ylim([-10 10])
grid on
##### 9 commentairesAfficher 7 commentaires plus anciensMasquer 7 commentaires plus anciens
Shai Katz le 22 Avr 2022
Thank you very much for you help, it works!
Do you know how can I plot them on geographic map? no just on a blank grid? I guess and need somehow to use the quiverm function..
Les Beckham le 22 Avr 2022
You are welcome.
Would you mind accepting the answer then?
Unfortunately, I don't have the mapping toolbox so I'm not going to be much help with that. Looking at the online doc, though, it looks pretty similar to quiver. You will probably need to play around with the scale argument to quiverm (using this syntax: h = quiverm(lat,lon,deltalat,deltalon,scale)) to use your u and v speed components as the deltalat and deltalon arguments.
Good luck.

Connectez-vous pour commenter.

### Plus de réponses (3)

Tala le 19 Avr 2022
Modifié(e) : Tala le 19 Avr 2022
I have done similar tasks before. If you have experimental data, your sensor should generate two time histories; velocity (Mag) and direction (Dir) with identical length, depending on your smapling frequency. To th ebest of knowledge, no sensor can read in 3D, you need to rotate your sensor if you want Z direction measurments.
You are right, direction could be tricky because small changes in wind direction could cause significant changes in the probe's reading. In other words, your probe could read between 350 and 10 degrees but in reallity these are all similar values. You need to be strategic about placing your probe at the right angle. If you avarage it out you get 180, completely opposite angle! The graph below shoes the issue:
I could not find the code that I used before, but I did something like this:
% truncating the first and last few data points
%nn= number of points you wanna truncate from the beginning
%mm= number of points you wanna truncate from the end
Vx=sum((Mag(nn:mm)).*cosd((Dir(nn:mm))))/(mm-nn+1); %V(i).cos(theta(i))/n
Vy=sum((Mag(nn:mm)).*sind((Dir(nn:mm))))/(mm-nn+1);
angle=atand(Vy/Vx);
% now you need to create a x y z domain (in your case lat lon height)
% Vz=0 in this case
quiver3(x,y,z,Vx,Vy,0);
Below is the plot I got from my experiments back in the day. I measured the wiind speed around buildings at 3 different heights.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

BHUKYA SAMA le 17 Sep 2023
i have matrix V(lat,lon,level,time) how to do dV/dZ, can i use gradient (V)/gradient (Z) ?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

BHUKYA SAMA le 17 Sep 2023
i am need to ccalculate the dV/dZ from era5, below code is okay?
clear all
close all
fclose all
%%%%%%%% Hlecity %%%%%%%%%55
u_wind_avg=0.5*(u1(1,1,26,1)-u1(1,1,37,1));%u(lon,lat,level,time)
v_wind_avg=0.5*(v1(1,1,26,1)-v1(1,1,37,1));%v(lon,lat,level,time)
for i=1:37
p0=1000;
ht(i)=8*log(level1(i)/p0);
end
ht1=-ht;
ht2=ht1*1000;
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Vector Fields dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by