This is a small thing but has been bothering me for a while now, so I thought I would let the crowd solving begin :)
I have a matrix with timestamps and a corresponding logical value (or 1/0), i.e.
of = [-inf 0 10 15 190 inf; 1 0 0 1 1 0]'
and an another time vector, e.g.
t = 0:0.1:1e3;
or whatever, you get the point :)
Now how do I (read: would you) inter-/extrapolate the logical infomation in of
so it matches the timestamps in t
, but with the interpolated logicals always assuming the last or current value, not a future one?
Don't know if that makes sense, but here is the expected output given of
and t2
t2 = [0 5 14 16]
output = [0 0 10 15; 0 0 0 1]'
where the first column of output
is the time of of
used in interpolation. If I use interp1
and the 'nearest' algorithm, it will give
interp1(of(:,1), of, t2, 'nearest')
output = [0 10 15 15; 0 0 1 1]'
which is not exactly what I want.