How to calculate mean wind direction
이전 댓글 표시
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
채택된 답변
추가 답변 (3개)
Jenna Marie
2014년 5월 5일
0 개 추천
댓글 수: 1
José-Luis
2014년 5월 5일
No worries.
doc numel
Counts the number of elements in the matrix.
Walter Roberson
2017년 7월 9일
0 개 추천
See unwrap() but you will need to convert to radians
Robert Daly
2021년 6월 16일
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
Soeren Bilges
2023년 2월 10일
Preferred and robust solution, thanks.
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!