Interpolation using the DFT Example Script: Difference between revisions
Jump to navigation
Jump to search
(Created page with '====Interpolation Using the DFT==== You can use the DFT to interpolate by adding zeros at high frequency in the DFT and then applying the inverse DFT to obtain the interpolated …') |
(No difference)
|
Latest revision as of 16:45, 15 November 2010
Interpolation Using the DFT
You can use the DFT to interpolate by adding zeros at high frequency in the DFT and then applying the inverse DFT to obtain the interpolated data. Note that high frequencies are the central points of the DFT. Play with the script below to learn all you can about interpolation using the DFT.
% This function investigates the effect of zero filling. clear; clg; N = 10; % Must be even for the fftshift part to work right. T = .1; t=0:T:(N-1)*T; x=sin(2*pi*t)+sin(2*pi*2*t); figure(1); plot(t,x,'ro'); xlabel('Time'); ylabel('x(t)'); title('Interpolation in Time Using the DFT') hold legend('Original Data') N1 = 30; X = fft(x); X1 = (N1+N)/N*[X(1:N/2),zeros(1,N1)*10,X(N/2+1:N)]; x1 = ifft(X1); t1=0:N/(N+N1)*T:(N-1/(N1+N))*T; plot(t1,x1,'bo') plot(t,x,'ro'); %legend('Original Data','Interpolated Data'); t2=0:.0001:1; plot(t2,sin(2*pi*t2)+sin(2*pi*2*t2),'c-')