%% Set timeseries Interpolation Method
% Set the interpolation method of a timeseries object in three ways.
% Create a timeseries object and set the interpolation method to zero-order hold.

ts = timeseries(rand(100,1),1:100);
ts = setinterpmethod(ts,'zoh');
plot(ts)

% Set the default interpolation method using a function handle.

fun = @(newtime,oldtime,olddata)...
               interp1(oldtime,olddata,newtime,...
                       'linear','extrap');
ts = setinterpmethod(ts,fun);
plot(ts)

% Set the default interpolation method to a tsdata.interpolation object.

interpobj = tsdata.interpolation(fun);
ts = setinterpmethod(ts,interpobj);
plot(ts)

% Copyright 2012 The MathWorks, Inc.