%-----------------------------------------------------------------
% *** 2.161 Signal Processing - Continuous and Discrete ***
% Tutorial MATLAB Function
%
% xinterp - simple radix-2 data interpolation function based on
% cardinal reconstruction.
%
% Source: Class handout: Data Resampling: Interpolation (Up-
% Sampling) and Decimation (Down-Sampling)
%
% Usage: fout = xinterp(fin, K)
% where fin - input vector of data,
% K - interpolation factor.
% The length of the interpolated data array fout will be 2^K times
% the length of the input array fin.
%
% Author: D. Rowell
% Revision: 2.0 9-23-2007
%
%------------------------------------------------------------------
%
function fout = xinterp(fin,K)
fdummy = fin;
% Repeat the procedure K times, each time doubling the length of
% the output array by inserting a point at the mid-point of the
% intervals.
for k = 1:K
N=size(fdummy,2);
% Create an empty output vector
fout = zeros(1,2*N);
for i=1:N
fout(2*i-1) = fdummy(i);
for j=1:N
fout(2*i) = fout(2*i) + fdummy(j)*(-1)^(j-i)/(i-j+0.5);
end
fout(2*i) = fout(2*i)/pi;
end
fdummy=fout;
end
%
fout=fdummy;