data extraction from a time series
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Binu
le 1 Fév 2022
Réponse apportée : Walter Roberson
le 1 Fév 2022
Hi I have a time seris data. I want to extract the data , for example, from 06:01:01 to 20:01:01 everyday. I have attached a few days of data as a sample.
Thank you
0 commentaires
Réponse acceptée
Walter Roberson
le 1 Fév 2022
I had to guess that you wanted to exclude 20:01:01 itself.
I wonder if what you would really want is "after 6 am (excluding 6 am), up to and include 8 pm" ? Or maybe 6 am (inclusive) up to but excluding 8 pm ?
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/880370/test%20data.xlsx';
opt = detectImportOptions(filename, 'readvariablenames', false);
opt = setvartype(opt, 1, 'datetime');
opt = setvaropts(opt, 1, 'InputFormat', 'uuuu-MM-dd HH:mm:ss');
T = readtable(filename, opt);
[h, m, s] = hms(T{:,1});
d = duration(h, m, s);
starttime = duration(06,01,01);
endtime = duration(20,01,1);
mask = isbetween(d, starttime, endtime, 'openright');
selected_T = T(mask,:);
selected_T(end-10:end,:)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Time Series 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!