Select multiple time ranges and variables in Timetable and create logical flag or filter
13 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Seth Furman
2022-2-28
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, :)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Timetables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!