Average sections of a timetable
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Poison Idea fan
il 22 Mar 2023
Modificato: Cris LaPierre
il 22 Mar 2023
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 Commenti
Cris LaPierre
il 22 Mar 2023
Modificato: Cris LaPierre
il 22 Mar 2023
How can you be sure that won't introduce the same data processing issue into your data?
Risposta accettata
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!