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?
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
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!