How to simultaneously use logical indexing and date time indexing in a timetable?

조회 수: 8 (최근 30일)
Hi,
Let's say I have a timetable with one of the variables being logical indexes, and I want to extract data from this timetable using that logical indexing from the timetable and a certain timerange at the same time. Doing something like this:
extracted_data = TT(trange & TT.Var_log_idx==true,'Var3');
I would like to be able to do this all in one statement. Hope that explains it, I have attached a mat file with a sample timetable and a timerange if you wish to try.
Any help is appreciated,
Thanks!

채택된 답변

HWIK
HWIK 2021년 9월 3일
Not to delete this question, I will answer it with what I found to be the closest to what I wanted through some documentation.
There are a bunch of functions which can do this: withinrange, containsrange and overlapsrange. Where, you can get the logical indexing using the second output of these functions:
[tf, idx] = withinrange(TT,trange);
  댓글 수: 1
Peter Perkins
Peter Perkins 2022년 3월 2일
Another possibility would be to and together the result of isbetween and the logical variable. timerange is essentially a wrapper around isbetween, which itself is just a wrapper around < and >.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by