EDIT: I'm now looking at the isbetween function in MATLAB
___________________
Hi all,
I'm a bit stuck on trying to build a sequence of events based on a truncated interval.
I have a vector, t3, containing datetimes and a vector, flags, containing sequence identifiers (1 for system up and 2 for down). I also have a vector, tInts, of datetimes for 5 minute intervals that span the entirety of t3.
So, for example, I have:
'2019-01-24 16:00:00'
'2019-01-24 16:00:04'
'2019-01-24 16:02:02'
'2019-01-24 16:03:36'
'2019-01-24 16:05:44'
'2019-01-24 16:06:12'
'2019-01-24 16:08:12'
'2019-01-24 16:09:13'
'2019-01-24 16:14:04'
'2019-01-24 16:14:35'
for t3,
flags = [2;1;2;1;2;1;2;1;2;1];
and tInts would be
'2019-01-24 16:00:00'
'2019-01-24 16:05:00'
'2019-01-24 16:10:00'
'2019-01-24 16:15:00'
I want to check that the values of t3 are within the 5 minute intervals in tInts, and, if they roll over, I want to insert an additional flag into a sequence. So, based on my example, at index 5 for t3, we exceed 5 minutes. The flags to that point are [2;1;2;1;2]; Now, I want to add an additional 1 (since it rolled over the 5 minutes in state 1) before the last 2, making
and on and on through all of t3.
So I have a thought to try an if-statement inside a for-loop where I have some condition that would look at a certain t3 element and check if the difference from tInts(j) - t3(1) >= 0 then seq = [flags upto i; flags(i-1)] else seq = flags up to i.
I'm not really sure. Any help would be great.
Thanks,
E