From discrete dates to continuous dates (revised)
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a timetable T like
city date visitors
-----------------------
NY January 1 2020 100
NY January 5 2020 40
NY January 12 2020 300
SF January 1 2020 70
SF January 6 2020 240
SF January 15 2020 30
I want to embed this in a larger table with continuous dates such as
city date visitors
-----------------------
NY January 1 2020 100
NY January 2 2020 NaN
NY January 3 2020 NaN
NY January 4 2020 Nan
NY January 5 2020 40
...
How can one do this?
댓글 수: 3
the cyclist
2020년 12월 8일
Can you upload the table you have in a MAT file, so that we don't have to guess at the date format?
Also, am I to understand that you do not want "2020" to appear in the added dates?
채택된 답변
Steven Lord
2020년 12월 8일
Here's a sample timetable.
dt = datetime(2020, 1, [1; 5; 12]);
T = timetable(dt, [100; 40; 300], 'VariableNames', "visitors");
T.Properties.DimensionNames{1} = 'date'
retime it either filling rows not appearing in the original with missing (the default) or with the constant 0
T_fillWithMissing = retime(T, 'daily')
T_fillWith0 = retime(T, 'daily', 'fillwithconstant', 'Constant',0)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Timetables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!