I have a 8760X30 matrix and I want to convert this matrix to 365X30 matrix.
Every values in the row indicates a value in hour and now by take average of every 24 values, I want to have the day matrix.
Can anybody help me with it??

 採用された回答

Stephen23
Stephen23 2020 年 2 月 11 日

0 投票

>> inp = rand(8760,30); % fake data matrix
>> out = mean(permute(reshape(inp,24,[],30),[2,3,1]),3);
And checking:
>> size(out)
ans =
365 30
>> isequal(mean(inp(1:24,:),1),out(1,:))
ans = 1

5 件のコメント

Ali Nouri
Ali Nouri 2020 年 2 月 11 日
thanks
Ali Nouri
Ali Nouri 2020 年 2 月 14 日
what if i want to take the hourly average of whole year? like the average of all those value at 12 clock. how can I do it??
Stephen23
Stephen23 2020 年 2 月 14 日
>> out = mean(permute(reshape(inp,24,[],30),[1,3,2]),3);
checking:
>> size(out)
ans =
24 30
>> isequal(mean(inp(1:24:end,:),1),out(1,:))
ans = 1
It might be clearer to use a table:
Ali Nouri
Ali Nouri 2020 年 2 月 14 日
Thanks.
Steven Lord
Steven Lord 2020 年 2 月 14 日
Since this is time-based data, I'd recommend a timetable instead of a table as that would let you do things like retime the timetable to a daily basis with one function call.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Timetables についてさらに検索

質問済み:

2020 年 2 月 11 日

コメント済み:

2020 年 2 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by