How to calculate mean wind direction
Mostrar comentarios más antiguos
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
2 comentarios
José-Luis
el 5 de Mayo de 2014
Instead of 0, you mean?
Jenna Marie
el 5 de Mayo de 2014
Respuesta aceptada
Más respuestas (3)
Jenna Marie
el 5 de Mayo de 2014
0 votos
1 comentario
José-Luis
el 5 de Mayo de 2014
No worries.
doc numel
Counts the number of elements in the matrix.
Walter Roberson
el 9 de Jul. de 2017
0 votos
See unwrap() but you will need to convert to radians
Robert Daly
el 16 de Jun. de 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 comentario
Soeren Bilges
el 10 de Feb. de 2023
Preferred and robust solution, thanks.
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!