How to find is between values for 1min datetime delta
Show older comments
Im trying to find indices from a datetime vector that are between certain time values. The delta between tupper and tlower is 1min
tlower=15:18:07
tupper= tlower+seconds(60)
= 15:19:07
tf = isbetween(timematch2,tlower,tupper);
However inthis case tf is a null vector and doest find the in between indices. Does it only work if duration delta in hrs?
%% the below case works %
tf=isbetween(timematch2,tlower,timematch2(end-1));
EDIT: Attached mat files instead of snippet
1 Comment
dpb
on 5 Dec 2020
tf = isbetween(timematch2,tlower,tupper)
I'll note the code snippet is using timematch2 not timematch that is mentioned. We don't know what the variable was the image is and can't do anything with images, anyway.
Attach a section of an array as .mat file that you think exhibits the symptom.
Accepted Answer
More Answers (1)
Your datetime array may not display the date data but it includes date data nonetheless.
d = datetime('now')
d2 = d; d2.Format = 'HH:mm:ss'
If you want to know if the datetime value is between certain times of day, use timeofday. You need to be a bit careful if your time range includes midnight.
isbetween(timeofday(d2), duration(12, 0, 0), duration(22, 0, 0))
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!