Average sections of a timetable
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Poison Idea fan
le 22 Mar 2023
Modifié(e) : Cris LaPierre
le 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 commentaires
Cris LaPierre
le 22 Mar 2023
Modifié(e) : Cris LaPierre
le 22 Mar 2023
How can you be sure that won't introduce the same data processing issue into your data?
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!