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!