How to convert 3 hourly data into a 6 hourly data?

3 ビュー (過去 30 日間)
Arun Nair
Arun Nair 2019 年 5 月 17 日
コメント済み: Arun Nair 2019 年 5 月 19 日
I have a 3D variable (time,latitude,longitude) every 3hourly (regular). I need to change this variable into 6 hourly by averaging (eg, 0hr and 3hr of old variable averaged, and stored as first time step in the new variable). In total my old variable has 56 time steps. How should I go about?

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 5 月 17 日
編集済み: Andrei Bobrov 2019 年 5 月 18 日
In R2016b
[m,n,k] = size(A);
t = hours(0:3:(k-1)*3);
Ar = reshape(A,m,[]);
TT = table2timetable(array2table(Ar),'RowTime',t(:));
T1 = retime(TT,TT.Time(1:2:end),'mean');
out = reshape(T1{:,:},[],n,k);
add:
[m,n,k] = size(A);
t = hours((0:m-1)*3)';
o1 = varfun(@mean,array2table([floor(t / hours(6)) + 1,reshape(A,m,[])]),...
'GroupingVariables','Var1');
out = reshape(o1{:,3:end},[],n,k);
  3 件のコメント
Andrei Bobrov
Andrei Bobrov 2019 年 5 月 18 日
Please see part 'add' in my answer.
Arun Nair
Arun Nair 2019 年 5 月 19 日
Thank you for your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePower and Energy Systems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by