-
Notifications
You must be signed in to change notification settings - Fork 1
/
lerpTimeSeries.m
33 lines (25 loc) · 924 Bytes
/
lerpTimeSeries.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [ varargout ] = lerpTimeSeries( varargin )
%LERPDATA Performs a linear interpolations on multiple vector time series
if nargin < 1
error('lerpVectors:argumentCheck', 'Not enough input arguments.');
end
if nargin ~= nargout
error('lerpVectors:argumentCheck', 'Number of output arguments must match number of input arguments.');
end
% merge time vectors
t = varargin{1}.Time;
for n=2:nargin
t = union(t, varargin{n}.Time);
end
% resample all time series
for n=1:nargin
ts = varargin{n};
% to aid extrapolation, pad at start and end
first = ts.Data(1, :);
last = ts.Data(end, :);
ts = addsample(ts, 'Data', first, 'Time', t(1));
ts = addsample(ts, 'Data', last, 'Time', t(end));
% resample the timeseries
varargout{n} = resample(ts, t);
end
end