how to calculate common dates from two date arrays?
I have two arrays with many datenums in format [startTime endTime]. I am trying to find a way to calculate all common datetimes (i.e duration), and end product should be new array where is all [startTime endTime] of all common datetimes.
Example (datenums are datetime for clarity in this example): dates1 array some row is :
[1.10.2025 10:00:00, 1.10.2025 13:00:00]
and some rows in dates2 are:
[1.10.2025 09:30:00, 1.10.2025 11:00:00]
[1.10.2025 12:30:00 ,1.10.2025 14:40:00]
so new array of common times will get rows
[1.10.2025 10:00:00, 1.10.2025 11:00:00]
[1.10.2025 12:30:00, 1.10.2025 13:00:00]
Tried to ask Grok but its function was erroneus. Greatly appreciate help!I have two arrays with many datenums in format [startTime endTime]. I am trying to find a way to calculate all common datetimes (i.e duration), and end product should be new array where is all [startTime endTime] of all common datetimes.
Example (datenums are datetime for clarity in this example): dates1 array some row is :
[1.10.2025 10:00:00, 1.10.2025 13:00:00]
and some rows in dates2 are:
[1.10.2025 09:30:00, 1.10.2025 11:00:00]
[1.10.2025 12:30:00 ,1.10.2025 14:40:00]
so new array of common times will get rows
[1.10.2025 10:00:00, 1.10.2025 11:00:00]
[1.10.2025 12:30:00, 1.10.2025 13:00:00]
Tried to ask Grok but its function was erroneus. Greatly appreciate help! I have two arrays with many datenums in format [startTime endTime]. I am trying to find a way to calculate all common datetimes (i.e duration), and end product should be new array where is all [startTime endTime] of all common datetimes.
Example (datenums are datetime for clarity in this example): dates1 array some row is :
[1.10.2025 10:00:00, 1.10.2025 13:00:00]
and some rows in dates2 are:
[1.10.2025 09:30:00, 1.10.2025 11:00:00]
[1.10.2025 12:30:00 ,1.10.2025 14:40:00]
so new array of common times will get rows
[1.10.2025 10:00:00, 1.10.2025 11:00:00]
[1.10.2025 12:30:00, 1.10.2025 13:00:00]
Tried to ask Grok but its function was erroneus. Greatly appreciate help! intersect, datetime MATLAB Answers — New Questions