Creating timetable from excel for rainfall data

1 回表示 (過去 30 日間)
NIKIL
NIKIL 2019 年 5 月 19 日
コメント済み: NIKIL 2019 年 5 月 20 日
Hello,
I am trying to import the excel data on hourly rainfall (attached) to calculate the daily, monthly, and annual rainfall.
Could anybody help me with creating timetable for the above dataset so that it would be possible to apply retime approach to calculate the daily/monthly?
Many thanks.

採用された回答

Guillaume
Guillaume 2019 年 5 月 19 日
Considering that excel has a perfectly working date/time time, one must wonder why you're not using it. At least, encoding the date and time as characters would make more sense than this completely non-standard date and time storage. In particular using hour 24 on the current day instead of hour 0 on the next day makes no sense at all.
badlyformatteddata = readtable('RAINFALL_HOURLY.xlsx');
rainfall = table2timetable(badlyformatteddata(:, 'RainMm'), 'RowTimes', datetime(compose('%d %06d', badlyformatteddata.Date, mod(badlyformatteddata.Time, 240000)), 'InputFormat', 'yyyyMMdd HHmmss'));
rainfall.Time(hour(rainfall.Time) == 0) = rainfall.Time(hour(rainfall.Time) == 0) + days(1) %To account for that stupid hour 24
  5 件のコメント
Guillaume
Guillaume 2019 年 5 月 20 日
編集済み: Guillaume 2019 年 5 月 20 日
Ah, ok, in that case, I would set the time to the beginning of the sampling instead of the end by subtracting 1 hour from all the times. This actually makes the decoding slightly simpler (and saner):
badlyformatteddata = readtable('RAINFALL_HOURLY.xlsx');
rainfall = table2timetable(badlyformatteddata(:, 'RainMm'), 'RowTimes', datetime(compose('%d %06d', badlyformatteddata.Date, badlyformatteddata.Time-10000), 'InputFormat', 'yyyyMMdd HHmmss'))
NIKIL
NIKIL 2019 年 5 月 20 日
Many thanks Guillaume.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by