%% Compare Linear Interpolation with FIR Interpolation
% Note: If you are using R2016a or earlier, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).

x = [1 4]; 
x = repmat(x,1,4);
x1 = 1:0.25:8;
firInterp = dsp.Interpolator('Method','FIR','FilterHalfLength',2,...
'InterpolationPoints',x1','InterpolationPointsPerSample',4);
linInterp = dsp.Interpolator('InterpolationPoints',x1');
OutFIR = firInterp(x');
OutLin = linInterp(x');
stem(OutFIR,'b-.','linewidth',2); 
hold on; 
stem(OutLin,'r','markerfacecolor',[1 0 0]);
axis([0 30 0 5]); 
legend('FIR','Linear','Location','Northeast');

% The interpolation points at indices 1 to 5 and 25 to 29 do not have enough low-rate samples surrounding them to use FIR interpolation with the specified filter length. Therefore, the interpolator object uses linear interpolation instead.
% Copyright 2012 The MathWorks, Inc.