Select multiple time ranges and variables in Timetable and create logical flag or filter
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello there,
A:
I would like to select multiple time ranges simultaneously in a Timetable.
I am trying to Flag these periods in a column of its own.
Currently, I have to do this twice, with two separate columns, as below, I would rather have one single flag:
Data{1}.Timestamp_Filter1 = Data{1}.Timestamp >= datetime("2020-01-01") & Data{1}.Timestamp <= datetime("2020-01-02");
Data{1}.Timestamp_Filter2 = Data{1}.Timestamp >= datetime("2022-01-01") & Data{1}.Timestamp <= datetime("2022-01-02");
I have already refered to:
B:
Similarly, but not for time ranges
Data{1}.angle_Filter3 = Data{idx}.angle >= 10 & Data{1}.angle <= 20;
Data{1}.angle_Filter4 = Data{idx}.angle >= 30 & Data{1}.angle <= 40;
How, can I do this once?
Support would be apprecaited. Thank you very much!
0 commentaires
Réponse acceptée
Seth Furman
le 28 Fév 2022
In this case we already know how to compute the rows we want using logical vectors, which we can use to index into the timetable directly.
TT = readtimetable("outages.csv")
rowTimes = TT.Properties.RowTimes;
isJan = month(rowTimes) == 1;
is1stThrough3rd = 1 <= day(rowTimes) & day(rowTimes) <= 3;
is2000s = 2000 <= year(rowTimes) & year(rowTimes) <= 2009;
isJan1stThrough3rd2000s = isJan & is1stThrough3rd & is2000s;
TT(isJan1stThrough3rd2000s, :)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Timetables 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!