필터 지우기
필터 지우기

retime only for specific gaps on time

조회 수: 9 (최근 30일)
Rub Ron
Rub Ron 2019년 8월 14일
편집: Akira Agata 2019년 8월 15일
I have a timetable z with more than 10 000 rows, this timetable should have a resolution of 15 minutes, but there are gaps of for example 30,45 minutes, 1, 5, 8 hours, or even days. So I would like to fill the missing data using retime but only for the gaps lower or equal to a specific gap (for example 1 hour). How can I do that? I have search for ways of doing that, but have found no hint. I am using this line, but it fills all the gaps.
retime(z,'regular','linear','TimeStep',minutes(15))
Any help would be very much appreciatted.
  댓글 수: 1
dpb
dpb 2019년 8월 14일
No builtin method I know of...first thought comes to my mind would be to build a corollary variable of the time gap values exceeding your threshold and then removing the interpolated rows between those time intervals after retime does its thing.

댓글을 달려면 로그인하십시오.

채택된 답변

Akira Agata
Akira Agata 2019년 8월 15일
편집: Akira Agata 2019년 8월 15일
How about the following solution?
% Sample timetable with 2 gaps (e.g >1 hour)
Time = datetime('now') + minutes(cumsum(45*rand(100,1)));
Time(30:end) = Time(30:end) + hours(1); % Gap1
Time(60:end) = Time(60:end) + hours(1); % Gap2
Data = rand(100,1);
TT = timetable(Time,Data);
% Find gaps and create group vector
idx = diff(TT.Time) > hours(1);
idx = [true; idx];
group = cumsum(idx);
% Apply retime function for each group and concatenate the result
TT2 = [];
for kk = 1:max(group)
idx = group == kk;
TT2 = [TT2; retime(TT(idx,:),'regular','linear','TimeStep',minutes(15))];
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by