%% Extrapolation Using Two Different Methods
% Define the sample points, x, and corresponding sample values, v.

x = [1 2 3 4 5];
v = [12 16 31 10 6];

%
% Specify the query points, xq, that extend beyond the domain of x.

xq = [0 0.5 1.5 5.5 6];

%
% Evaluate v at xq using the 'pchip' method.

vq1 = interp1(x,v,xq,'pchip')

%
% Next, evaluate v at xq using the 'linear' method.

vq2 = interp1(x,v,xq,'linear')

%
% Now, use the 'linear' method with the 'extrap' option.

vq3 = interp1(x,v,xq,'linear','extrap')

% 'pchip' extrapolates by default, but 'linear' does not.
% Copyright 2015 The MathWorks, Inc.