Autocomplete the datetime series

2 次查看(过去 30 天)
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 中查找有关 Sensors and Transducers 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by