datetime.interp1
datetime: VI = interp1 (X, V, XI)
datetime: VI = interp1 (…, method)
datetime: VI = interp1 (…, method, extrap)
One-dimensional interpolation involving datetime arrays.
VI = interp1 (X, V, XI) interpolates to find
VI, the values of the underlying function V = f
(X) at the query points XI. Datetime arrays are handled by
interpolating on their absolute (POSIX) instants:
The optional method ('linear' by default) and extrap
arguments are passed to the built-in interp1 (see its documentation
for the supported interpolation methods and extrapolation options). Query
points outside the range of X, and Not-A-Time query points, yield
NaN or NaT unless extrapolation is requested.
Source Code: datetime
interp1 interpolates values sampled at datetimes. Here numeric readings taken on 1 and 5 January are interpolated at 3 January.
t = datetime (2024, 1, [1, 5])
t =
1x2 datetime array
01-Jan-2024 05-Jan-2024
v = [10, 50]; interp1 (t, v, datetime (2024, 1, 3))
ans = 30
When the sampled values are datetimes, the interpolated result is a datetime.
interp1 ([0, 10], datetime (2024, 1, [1, 11]), 2.5)
ans = datetime 03-Jan-2024 12:00:00