Hourly and 6-hourly average of data in timeable

11 ビュー (過去 30 日間)
Phoebe Armitage
Phoebe Armitage 2021 年 1 月 2 日
回答済み: Eric Sofen 2021 年 1 月 5 日
How would I take an hourly and 6-hourly average of this data?
IM1TT =
2899×2 table
Date & Time IM1 Stress
____________________ __________
31-May-2010 14:50:00 NaN
31-May-2010 15:00:00 NaN
31-May-2010 15:10:00 6.9
31-May-2010 15:20:00 2.1
31-May-2010 15:30:00 6.3
31-May-2010 15:40:00 5.2
31-May-2010 15:50:00 NaN
31-May-2010 16:00:00 NaN
31-May-2010 16:10:00 3.2
31-May-2010 16:20:00 NaN

採用された回答

Eric Sofen
Eric Sofen 2021 年 1 月 5 日
If you want the rolling average, use smoothdata, with 'movmean' as the method and (e.g.) hours(6) as the window. If you want non-overlapping hourly/6-hourly averages, use retime. There will be two different ways to use retime, as hourly averaging is built-in:
retime(tt,'hourly','mean')
whereas you'll want to specify the time vector or timestep for the 6-hour averages. If you just specify the timestep, the 6-hour bins start from the start of your data:
retime(tt,'regular','mean','TimeStep',hours(6))
or
retime(tt,datetime(2010,5,31,12,0,0):hours(6):<whatever end time>,'mean')

その他の回答 (1 件)

Mischa Kim
Mischa Kim 2021 年 1 月 2 日
Phoebe, it looks like your data points are all equally spaced(?), 10 minutes. Check out the movmean() command.

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by