I need help with converting hourly data to daily summation inside a cell

1 回表示 (過去 30 日間)
BN
BN 2021 年 8 月 15 日
コメント済み: BN 2021 年 8 月 16 日
Dear all,
I have a cell that contains hourly data of precipitation for the period 1987-2016. I want to convert these hourly data to the daily sum. I tried doing this using timetable and then retime,
daily_precip = cellfun(@(x) table2timetable(x,'RowTime','date'), example, 'uniformoutput', false);
output = retime(daily_precip,'daily','sum');
but I got an error.
Error in @(x)table2timetable(x,'RowTime','date')
So how to convert my hourly data to the daily sum for all the three tables inside the cell?
I attached my cell (namely example).
Thank you

採用された回答

Yazan
Yazan 2021 年 8 月 15 日
編集済み: Yazan 2021 年 8 月 15 日
Note that the data type in the column date is char, not datetime. Try the following:
clc, clear
load('example.mat');
data = cell(size(example));
for ncell=1:length(example)
data{ncell} = timetable(datetime(example{ncell}.date, 'Format', 'dd-MMM-yyyy HH:mm:ss'), example{ncell}.precip);
end
daily_precip = cellfun(@(x) retime(x, 'daily', 'sum'), data, 'UniformOutput', false);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by