Find overlapping days across two datetime variables

Hey there,
I have two datetime variables "Hot_days (520x1)" and "Drought_days (1974x1)" that lists days since 2009 which experienced hot and dry conditions respectively. Now I would like to find the days that experiened BOTH dry and hot conditions. In other words, I would like to find the days that overlap with each other across the two different datetime variables.
Thank you in advance!

 채택된 답변

%random data
dt1=datetime(2022,6,1):datetime(2022,7,27); %1st June to Today
dt2=datetime(2022,7,1):datetime(2022,9,1); %1st July to 1st September
intersect(dt1,dt2)
ans = 1×27 datetime array
01-Jul-2022 02-Jul-2022 03-Jul-2022 04-Jul-2022 05-Jul-2022 06-Jul-2022 07-Jul-2022 08-Jul-2022 09-Jul-2022 10-Jul-2022 11-Jul-2022 12-Jul-2022 13-Jul-2022 14-Jul-2022 15-Jul-2022 16-Jul-2022 17-Jul-2022 18-Jul-2022 19-Jul-2022 20-Jul-2022 21-Jul-2022 22-Jul-2022 23-Jul-2022 24-Jul-2022 25-Jul-2022 26-Jul-2022 27-Jul-2022

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

릴리스

R2021b

태그

질문:

2022년 7월 27일

댓글:

2022년 7월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by