Calculating weekly mean from daily data.
7 ビュー (過去 30 日間)
古いコメントを表示
I have a netcdf file with u and v components for wind. I want to calculate the weekly averages of the u and v components based off of daily data.
so far I have
[y,mo,d] = datevec(dn);
xm = zeros(120,1);
for i = 1:120
if d = 1:7
xm(i) = mean(v_vector(d == i));
elseif d = 8:14
xm(i) = mean(v_vector(d == i));
elseif d = 15:23
xm(i) = mean(v_vector(d == i));
elseif d = 24:21
xm(i) = mean(v_vector(d == i));
end
dn is the date number. where 1 to 120 is the time increments from 1-Jan-2009 to 31-April-2009.
Thanks in advance
0 件のコメント
採用された回答
Eric Lin
2015 年 6 月 18 日
First, I would recommend finding a reliable method of determining the week number of a particular date. If you have access to R2014b or later, you can use the week function. An alternative is also available on MATLAB File Exchange.
From there, you can use a loop and logical indexing to find the means of each week:
%sample dates
t = datetime(2015,05,31):datetime(2015,06,18)
%week numbers
w = week(t)
%sample data
data = randi(10,1,19)
%mean for week 24
mean_24 = mean(data(w == 24))
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で NetCDF についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!