% 'interp_01.m'
% Interpolation using standard MATLAB tools;


function interp_01

echo off, clc
clear all


x = 0:10; y = sin(x); xi = 0:.25:10;
yi1 = interp1(x,y,xi,'nearest'); 
yi2 = interp1(x,y,xi,'linear');
yi3 = interp1(x,y,xi,'spline');
% Warning - no explicit information about function
% derivatives is provided!
yi4 = interp1(x,y,xi,'pchip');

figure(1); plot(x,y,'o',xi,yi1,'-b',xi,yi2,':r',xi,yi3,'-g',xi,yi4,'-.m');
legend('actual','nearest', 'linear', 'cubic spline', 'Hermite');



