Time weighted average after every 60mins
3 次查看(过去 30 天)
显示 更早的评论
please i have a sample data as in the picture, and want to find the time weighted average after every 60 mins of the spread column
回答(2 个)
Cris LaPierre
2020-10-27
Look into groupsummary. You'll probably want something like this. I'm assuming your data is in a table.
groupsummary(tblName,Date.time,'hour','mean',spread)
I wouldn't call this a weighted average, though. You'll need to provide more details about how you want to time-weight the average.
0 个评论
Peter Perkins
2020-11-20
Or put the data in a timetable and use retime(tt,'hourly','mean'). If you need weights, you can write your own aggregation function for hourly aggregation.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!