Filling in gaps of missing data with a time series

조회 수: 5 (최근 30일)
drb17135
drb17135 2021년 11월 17일
답변: Star Strider 2021년 11월 17일
Hi, I have a set of data that ranges from two date times and has data allocated to each time. I am looking to replace any missing time data points with the nearest neighbour method.
this is what I have so far:
CI_pre = string(readcell('CarbonIntensityCombined.xlsm', 'Sheet','JantoDec_2022-2024','Range','A2:A52609'));
CI_pre = split(CI_pre,{'T',':','Z'});
CI_pre = join(CI_pre);
CI2 = replaceBetween(CI_pre,14,14,':');
CI_check = datetime(c2);
% % create an array of datetime ranging from 1/1/2022 to 31/12/24
% increasing in 30 minute increments
T1_CI = daHi, I have a set of data that ranges from two date times and has data allocated to each time. I am looking to replace any missing time data points with the nearest neighboutetime('2022-01-01 00:00:00');
T2_C2 = datetime('2024-12-31 23:30:00');
t= (T1_CI:minutes(30):T2_C2)';
% check there is no missing days in the data´
idx = ismember(CI_check,t);
CImissing = t(~idx);
the CI_check data looks like this:
'01-Jan-2022 00:00:00'
'01-Jan-2022 00:30:00'
'01-Jan-2022 01:00:00'
'01-Jan-2022 01:30:00'
and so on (incresing in 30 minutes)
and the data associated with it are just numbers
if there is missing data how do I retime this and replace the values with the nearest neighbour method?
I am aware I might need to use retime or make a timetable but I keep getting errros.
Thanks

채택된 답변

Star Strider
Star Strider 2021년 11월 17일
Change the table to a timetable (table2timetable), then use retime and the 'nearest' method.
.

추가 답변 (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