duration.interp1
duration: YI = interp1 (X, Y, XI)
duration: YI = interp1 (Y, XI)
duration: YI = interp1 (…, method)
duration: YI = interp1 (…, method, extrapolation)
duration: pp = interp1 (X, Y, 'pp')
duration: pp = interp1 (X, Y, method, 'pp')
One-dimensional interpolation for duration arrays.
YI = interp1 (X, Y, XI) computes the
linearly interpolated values of a one-dimensional function, which is
represented by sample points X and corresponding values Y,
at specific query points XI. X must be a vector. If Y
is vector, then it must have the same length as X. If Y is
matrix, then each column is treated as a different set of one-dimensional
sample values and the number of rows must equal the length of X.
XI must be a vector and the same data type as X. The output
XI is the same data type as Y and its size depends on Y
and XI. X and Y can both be duration arrays or one of
them can be a numeric array.
YI = interp1 (Y, XI) computes the linearly
interpolated values of a one-dimensional function assuming a default set
of sampling points determined by the shape of Y:
[1:length(Y).
[1:size(Y).
YI = interp1 (…, method) specifies one of the
following interpolation methods to be used:
'linear' (default) computes the linear interpolation from
nearest neighbors.
'nearest' returns the nearest neighbor.
'next' returns the next neighbor.
'previous' returns the previous neighbor.
'pchip' computes the piecewise cubic Hermite interpolating
polynomial, which corresponds to shape-preserving interpolation with
smooth first derivative.
'cubic' computes the cubic interpolation.
'spline' computes the cubic spline interpolation, which
corresponds to smooth first and second derivatives throughout the curve.
YI = interp1 (…, method, extrapolation)
further specifies a strategy for evaluating points that lie outside the
range of the sample points in X. Set extrapolation to
'extrap' to use the current method to extrapolate values.
Set extrapolation to a scalar value of the same data type as
Y to return a constant value outside the range of X. When
unspecified, extrapolation defaults to NaN.
pp = interp1 (X, Y, returns a
piecewise polynomial object, using the default linear interpolation
algorithm, which can be later used with 'pp'ppval to evaluate the
interpolation at new query points.
pp = interp1 (X, Y, method,
return a piecewise polynomial object, using the interpolation algorithm
specified by method, which can be later used with 'pp'ppval to
evaluate the interpolation at new query points.
Source Code: duration
interp1 interpolates duration-valued data at new sample points — useful for resampling a time series measured in durations.
t = hours ([0, 1, 2]); v = minutes ([10, 20, 40]); interp1 (t, v, hours (0.5))
ans = duration 15 min