Select multiple time ranges and variables in Timetable and create logical flag or filter
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Malik
el 24 de Feb. de 2022
Comentada: Malik
el 4 de Mzo. de 2022
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 comentarios
Respuesta aceptada
Seth Furman
el 28 de Feb. de 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, :)
Más respuestas (0)
Ver también
Categorías
Más información sobre Timetables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!