How to find average monthly wind velocity values for given years?

조회 수: 12 (최근 30일)
Scott Muir
Scott Muir 2021년 2월 25일
댓글: Adam Danz 2022년 9월 16일
I am new to MatLab and trying to create an average monthly wind velocity array for three separate years (2017-19), which I can then plot against each other and finally calculate the accumulated monthly mean from 2017-19.
This is the table formatting
How would I separate each year and determine the monthly mean wind velocities, which I can then insert into a line chart such as this (below) showing each year?
  댓글 수: 3
Scott Muir
Scott Muir 2021년 2월 26일
Thanks for the reply,
for some reason I cannot send my file:
Cannot attach this file because:
  • The server was unable to complete your request. Please try again later.
This is the message I received when attempting to send it.
also attempted to zip the file and send it that way.
Scott Muir
Scott Muir 2021년 2월 26일
편집: Scott Muir 2021년 2월 26일
I believe I have now included the relevant documents.

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2021년 2월 26일
Use groupsummary to compute the means for 12 months across all days/years.
Demo:
T = table((1:10)', randi(12,10,1), 2017.*ones(10,1), randi(20,10,1)+200, rand(10,1)*20, ...
'VariableNames', {'Day','Month','Year','WindDirection','WindSpeed'})
T = 10x5 table
Day Month Year WindDirection WindSpeed ___ _____ ____ _____________ _________ 1 8 2017 210 16.225 2 4 2017 202 18.072 3 6 2017 208 18.326 4 5 2017 215 12.933 5 1 2017 220 10.287 6 10 2017 204 2.1927 7 8 2017 205 4.0338 8 6 2017 219 11.377 9 2 2017 202 1.3805 10 8 2017 206 8.2965
groupsummary(T,'Month','mean',{'WindDirection','WindSpeed'})
ans = 7x4 table
Month GroupCount mean_WindDirection mean_WindSpeed _____ __________ __________________ ______________ 1 1 220 10.287 2 1 202 1.3805 4 1 202 18.072 5 1 215 12.933 6 2 213.5 14.851 8 3 207 9.5186 10 1 204 2.1927
  댓글 수: 2
Naseef Muhammed
Naseef Muhammed 2022년 9월 9일
Taking arithmatic means of wind direction is wrong. For example, based on 'groupsummary' average of 358 and 6 degree will results in 182 which is abselutely wrong.
Adam Danz
Adam Danz 2022년 9월 16일
@Naseef Muhammed, true, for circular data you'd want to compute the circular average.
Note that the demo data in my answer are all within the interval [200:220] so the regular old mean would return the same as the circular mean in this case.
Fortunately, groupsummary accepts function handles in the method argument.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by