How to calculate mean wind direction
Afficher commentaires plus anciens
Hello!
I need help figuring out how to calculate mean wind direction when my data is in degrees (0-360). I just realized my current program does not take into account that the data is circular, and the mean of 355 and 5 will be 180, instead of 0. Any help is greatly appreciated! I am a beginner when it comes to MATLAB programming
Réponse acceptée
Plus de réponses (3)
Jenna Marie
le 5 Mai 2014
0 votes
1 commentaire
José-Luis
le 5 Mai 2014
No worries.
doc numel
Counts the number of elements in the matrix.
Walter Roberson
le 9 Juil 2017
0 votes
See unwrap() but you will need to convert to radians
Robert Daly
le 16 Juin 2021
I needed a solution that would ignore NAN values in the data.
Converts the direction data into X & Y vector components, averages those, then converts back to direction.
function [windir_avged] = windir_avg(windir)
[x,y] = pol2cart(deg2rad(windir),ones(size(windir)));
x=mean(x,'omitnan');
y=mean(y,'omitnan');
[windir_avged,~]=cart2pol(x,y);
windir_avged = rad2deg(windir_avged);
end
1 commentaire
Soeren Bilges
le 10 Fév 2023
Preferred and robust solution, thanks.
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!