%----------------------------------------------------------------- % *** 2.161 Signal Processing - Continuous and Discrete *** % Tutorial MATLAB Function % % dftupsample - Tutorial data interpolation (up-sampling) using the DFT % % Source: Class handout: Data Resampling: Interpolation (Up-Sampling) % and Decimation (Down-Sampling) % % Usage: fout = dftupsample(f, K) % where f - is an input data record (real) of length N, % fout - is the output record of length KN, and K is the integer % interpolation factor, that is (K-1) interpolated data points % will be inserted between each of the original data points. % % % Author: D. Rowell % Revision: 1.0 10-1-2007 % %------------------------------------------------------------------- % function fout = dftupsample(fin,K) % N = length(fin); % Take the DFT Fin = fft(fin); % Pad the center of the DFT with zeros. Fout = zeros(length(Fin)*K,1); Fout(1:N/2) = Fin(1:N/2); Fout(N*K - N/2+1: N*K) = Fin(N/2+1:N); % Take the inverse DFT and preserve the real part fout = real(ifft(Fout))*K;