How do I use movsum with a timetable?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a 79880x42 timetable:
Date Station1 Station2 Station3
01-Jan-2011 00:00:00 0 0 0
01-Jan-2011 01:00:00 0.3 0 0
01-Jan-2011 02:00:00 0.4 0 0.6
I want to use movsum function to get the moving sum of 2 hours, 3 hours...12 hours of each station.
So far I have tried M2h = movsum(tt,k,'SamplePoints',Date), where tt=timetable, k=duration (2 hours), Date=datetime vector. But trying different variations of this function only gives me different errors such as "Invalid data type. First input must be numeric or logical." or "Unrecognized function or variable 'Date'.".
댓글 수: 0
답변 (1개)
Walter Roberson
2021년 2월 22일
Date = datetime('now') - (days(30):days(-1):days(0)).';
Station1 = sort(rand(31,1));
tt = timetable(Date, Station1)
k = hours(randi(7))
M2h = movsum(tt.Station1, k, 'SamplePoints', tt.Date)
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!