Autocomplete the datetime series

조회 수: 2 (최근 30일)
Poulomi Ganguli
Poulomi Ganguli 2017년 8월 28일
편집: KL 2017년 8월 28일
Hello, I have a time series as attached. The first, second, third and fourth column contains year, day, month, and hour, where the hour column runs from 0 - 23h. However, from 1st March, 23h onwards, no data are available. I want to create a datetime field from 1946, 2nd March onwards which ends at 31st December, with time frames 0-23 hrs. The value field can be filled with NaN in this case. Likewise, I have many sets of years and want to generalize the code in which the code can identify the enddate and endtime for which the data ends/missing and complete the datetime series till the end of the year, i.e.,
1946 12 31 23 NaN
Any help in this?

채택된 답변

KL
KL 2017년 8월 28일
편집: KL 2017년 8월 28일
something like this? Try with a bigger dataset with occasional gaps.
ts_ref = (datetime('01/01/1946 00:00:00'):hours(1):datetime('01/02/1946 00:00:00'))'; %timestamp with no gaps
ts_act = ts_ref;
ts_act(15:18)=[]; %create some gaps (your datetime vector)
val = rand(size(ts_act));
newVal = nan(size(ts_ref));
dummy_data = table(ts_act,val)
[~, ind_ts_ref, ind_ts_act] = intersect(ts_ref,ts_act);
newVal(ind_ts_ref) = val;
dummy_data_new = table(ts_ref,newVal)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by