Average sections of a timetable
11 次查看(过去 30 天)
显示 更早的评论
I have a data timetable. One of the variables is a flag that determines sample time and background time. For the purposes of my data processing, I want to average the sample times to 1 minute intervals.
Currently, I extract the rows with filterstate == 0 and use retime, then I concatenate the timetables and sort the rows in time. This creates an artifact where the first sample time will be rounded to the previous minute and creates a data processing issue.
Is there a better way to do this, or could I specify in retime to round to the next minute?
load example_tt.mat
% EDIT to show raw data
example_tt(6612:6635,:)
example_avg = retime_sample(example_tt);
example_avg(885:910,:)
function [raw_TT_retimed] = retime_sample(raw_TT)
% Take a raw data timetable and convert the sample times to 1 minute
% averages
sample_times = raw_TT(raw_TT.('filter state') == 0,:);
sample_times = retime(sample_times,"regular",'mean','TimeStep',minutes(1));
raw_TT_retimed = [sample_times;raw_TT(raw_TT.('filter state')==1,:)];
raw_TT_retimed = sortrows(raw_TT_retimed,'Time');
end
2 个评论
Cris LaPierre
2023-3-22
编辑:Cris LaPierre
2023-3-22
How can you be sure that won't introduce the same data processing issue into your data?
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Timetables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!