This question is closed. Reopen it to edit or answer.

Analyzing the rows of a timetable,I want to take the range from door/closed to door/open and study2cases:1.if there are no rows between door/closed and door/open and their time difference is> 20 minutes ;2.if there are rows between them.How can I do?

1 view (last 30 days)
Erica Corradi
Erica Corradi on 27 Jul 2018
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello to all. I have a time table (new_ita9TT) that contains data from different motion sensors. The column called Column1streamId contains the names of the sensors; the column called Column1type contains the type of rule (in this problem, I'm interested in door / open and door / closed). The analysis I want to do is as follows: I go to see the first door / closed that is in the Column1type column, referred to the sensor called dbuid-3; then I go to look for the following door / open (again referred to the dbuid-3) e - if there are no other lines between the door / closed and the door / open of the dbuid-3 and their time difference (which is in the ColumnDateTime column) is greater than 20 minutes, then save the data in a new table which will correspond to the patient left out of the house; - if between the door / closed and the door / open (again referred to the dbuid-3) there are other lines, then save this data in another table which will correspond to the patient at home.
Warning: the door / closed and the door / open can also be referred to other sensors, so it is important to specify the name of the sensor that interests me, ie dbuid-3; it is also important to start from the door / closed (of the dbuid-3) and since surely before the door / closed there will be a door / open, this door / open do not want to consider it.
Can someone help me?

Answers (1)

Peter Perkins
Peter Perkins on 3 Aug 2018
That's kind of a complicated explanation, and I'm not sure I can follow it completely. It sounds like you want to use categorical variables for your sensor IDs and types, and search though those variables for a combination that you are interested in. Something like
dbuid3OpenEvents = tt.ID == 'dbuid-3' && tt.Event == 'open';
dbuid3CloseEvents = tt.ID == 'dbuid-3' && tt.Event == 'close';
opened = cumsum(dbuid3OpenEvents) - cumsum(dbuid3CloseEvents);
dbuid3State = categorical(opened,[0 1],{'closed' 'opened'};
and then work from there to get the rows you want. This assumes that for every open there is a close.

Community Treasure Hunt

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

Start Hunting!