fast fourier transform fourier series transform summary
play

Fast Fourier Transform Fourier Series & Transform Summary - PowerPoint PPT Presentation

Fast Fourier Transform Fourier Series & Transform Summary Discrete-time windowing X [ k ] e jk o n x [ n ] = Discrete Fourier Transform k = <N> Relationship to DTFT X [ k ] = 1 x [ n ]e jk o n N


  1. Fast Fourier Transform Fourier Series & Transform Summary • Discrete-time windowing � X [ k ] e jk Ω o n x [ n ] = • Discrete Fourier Transform k = <N> • Relationship to DTFT X [ k ] = 1 � x [ n ]e − jk Ω o n N • Relationship to DTFS n = <N> • Zero padding x [ n ] = 1 � X (e jω ) e j Ω n dΩ 2 π 2 π ∞ � X (e jω ) = x [ n ] e − j Ω n n = −∞ • What are the similarities and differences between the DTFS & DTFT? J. McNames Portland State University ECE 223 FFT Ver. 1.03 1 J. McNames Portland State University ECE 223 FFT Ver. 1.03 2 Periodic Signals Example 1: Relationship to Fourier Series Suppose that we have a periodic signal x p [ n ] with fundamental period ∞ FT � � X [ k ] e jk Ω o n N . Define the truncated signal x [ n ] as follows. x [ n ] = ⇐ ⇒ 2 π X [ k ] δ (Ω − k Ω o ) k = <N> k = −∞ � x p [ n ] n 0 + 1 ≤ n ≤ n 0 + N x [ n ] = • Recall that DT periodic signals can be represented by the DTFT 0 otherwise • Requires the use of impulses (why?) Determine how the Fourier transform of x [ n ] is related to the • This makes the DTFT more general than the DTFS discrete-time Fourier series coefficients of x p [ n ] . Recall that X p [ k ] = 1 � x p[ n ]e − jk (2 π/N ) n N n = <N> J. McNames Portland State University ECE 223 FFT Ver. 1.03 3 J. McNames Portland State University ECE 223 FFT Ver. 1.03 4

  2. Example 1: Workspace DFT Estimate of DTFT � w [ n ] x [ n ] 0 ≤ n ≤ N − 1 x w [ n ] = x [ n ] · w [ n ] = 0 Otherwise X w (e jω ) = 1 2 π X (e jω ) ⊛ W (e jω ) • Recall that windowing in the time domain is equivalent to filtering (convolution) in the frequency domain • We found earlier that a windowed signal x w [ n ] = x [ n ] · w [ n ] could be thought of as one period of a periodic signal x p [ n ] • This enables us to calculate the DTFT at discrete-frequencies using the discrete-time Fourier series analysis equation! • Advantages – DTFS consists of a finite sum - we can calculate it – DTFS can be calculated very efficiently using the Fast Fourier Transform (FFT) J. McNames Portland State University ECE 223 FFT Ver. 1.03 5 J. McNames Portland State University ECE 223 FFT Ver. 1.03 6 FFT Estimate of DTFT Derived DFT, FFT, and DTFS X [ k ] = 1 + ∞ � x [ n ]e − jk Ω o n DTFS X w (e jω ) � x w [ n ]e − j Ω n = N n = <N> n = −∞ N − 1 N − 1 � x w [ n ]e − jk 2 π N n DFT/FFT X w [ k ] = � x w [ n ] e − j Ω n = n =0 n =0 • Note abuse of notation, X [ k ] N − 1 x w [ n ]e − jk 2 π X w (e jω ) � N n � = • The DFT is a transform � Ω= k 2 π N n =0 • The FFT is a fast algorithm to calculate the DFT = DFT { x w [ n ] } • If x [ n ] is a periodic signal with fundamental period N , then the • Calculation of the DTFT of a finite-duration signal at discrete DFT is the same as the scaled DTFS frequencies is called the Discrete Fourier Transform (DFT) • The DFT can be applied to non-periodic signals • The FFT is just a fast algorithm for calculating the DFT – For non-periodic signals this is modelled with windowing • The DTFS cannot J. McNames Portland State University ECE 223 FFT Ver. 1.03 7 J. McNames Portland State University ECE 223 FFT Ver. 1.03 8

  3. Example 2: FFT Estimate of DTFT Example 2: Workspace Solve for the Fourier transform of ⎧ − 1 1 ≤ n ≤ 4 ⎪ ⎨ x [ n ] = +1 13 ≤ n ≤ 16 ⎪ 0 Otherwise ⎩ J. McNames Portland State University ECE 223 FFT Ver. 1.03 9 J. McNames Portland State University ECE 223 FFT Ver. 1.03 10 Example 2: Workspace Example 2: Signal 1 0.8 0.6 0.4 0.2 x[n] 0 −0.2 −0.4 −0.6 −0.8 −1 0 2 4 6 8 10 12 14 16 Time J. McNames Portland State University ECE 223 FFT Ver. 1.03 11 J. McNames Portland State University ECE 223 FFT Ver. 1.03 12

  4. Example 2: DTFT Estimate Zero Padding X w (e jω ) � N = DFT { x w [ n ] } 5 � Ω= k 2 π Real X(e j ω ) 0 • The FFT has two apparent disadvantages – It requires that N be an integer power of 2: N = 2 ℓ −5 True DTFT DFT Estimate – It only generates estimates at N frequencies equally spaced −10 between 0 and 2 π rad/sample 0 0.5 1 1.5 2 2.5 3 • Both of these problems can be circumvented by zero-padding 10 • Recall that x w [ n ] = x [ n ] · w [ n ] Imag X(e j ω ) 5 • We can choose N to be larger than the length of our window w [ n ] 0 −5 0 0.5 1 1.5 2 2.5 3 Frequency (rads per sample) J. McNames Portland State University ECE 223 FFT Ver. 1.03 13 J. McNames Portland State University ECE 223 FFT Ver. 1.03 14 Zero Padding Derived Example 3: FFT Estimate of DTFT Repeat the previous example but use zero-padding so that the estimate Suppose we add M − N zeros to the finite-length signal x [ n ] such is evaluated at no less than 1000 frequencies between 0 and π . that M is an integer power of 2 and M ≥ N . Then the zero-padded signal, x z [ n ] , has a length M . The frequency resolution then improves to 2 π M rad/sample, rather than 2 π N rad/sample. N − 1 x w [ n ]e − j ( k 2 π N ) n � DFT { x w [ n ] } = n =0 M − 1 x z [ n ]e − j ( k 2 π M ) n � DFT { x z [ n ] } = n =0 N − 1 x w [ n ]e − j ( k 2 π M ) n � = n =0 X w (e jω ) � = DFT { x z [ n ] } � Ω= k 2 π M J. McNames Portland State University ECE 223 FFT Ver. 1.03 15 J. McNames Portland State University ECE 223 FFT Ver. 1.03 16

  5. Example 3: DTFT Estimate with Padding Example 3: MATLAB Code %function [] = FFTEstimate(); 5 close all; n = 0:17; Real X(e j ω ) x = -1*(n>=1 & n<=4) + 1*(n>=13 & n<=16); 0 %============================================================================== % Plot the signal %============================================================================== −5 figure True DTFT FigureSet(1,4.5,2.8); DFT Estimate plot([min(n) max(n)],[0 0],’k:’); hold on; −10 h = stem(n,x,’b’); 0 0.5 1 1.5 2 2.5 3 set(h(1),’MarkerFaceColor’,’b’); set(h(1),’MarkerSize’,4); hold off; 10 ylabel(’x[n]’); xlabel(’Time’); xlim([min(n) max(n)]); Imag X(e j ω ) ylim([-1.05 1.05]); 5 box off; AxisSet(8); print -depsc FFTESignal; 0 %============================================================================== % Plot the True Transform \& Estimate %============================================================================== n = 1:16; −5 x = -1*(n>=1 & n<=4) + 1*(n>=13 & n<=16); 0 0.5 1 1.5 2 2.5 3 N = length(x); k = 0:N-1; Frequency (rads per sample) we = (0:N-1)*(2*pi/N); % Frequency of estimates Xe = exp(-j*k*(2*pi/N)*1).*fft(x); J. McNames Portland State University ECE 223 FFT Ver. 1.03 17 J. McNames Portland State University ECE 223 FFT Ver. 1.03 18 w = 0.0001:(2*pi)/1000:2*pi; figure X = (-exp(-j*w*1) + exp(-j*w*5) + exp(-j*w*13) - exp(-j*w*17))./(1-exp(-j*w)); % True spectrum FigureSet(1,’LTX’); subplot(2,1,1); figure h = plot(w,real(X),’r’,we,real(Xe),’k’); FigureSet(1,’LTX’); set(h(1),’LineWidth’,2.0); subplot(2,1,1); set(h(2),’LineWidth’,1.0); h = plot(w,real(X),’r’,we,real(Xe),’k’); ylabel(’Real X(e^{j\omega})’); set(h(2),’Marker’,’o’); xlim([0 pi]); set(h(2),’MarkerFaceColor’,’k’); box off; set(h(2),’MarkerSize’,3); AxisLines; ylabel(’Real X(e^{j\omega})’); legend(h(1:2),’True DTFT’,’DFT Estimate’,4); xlim([0 pi]); subplot(2,1,2); box off; h = plot(w,imag(X),’r’,we,imag(Xe),’k’); AxisLines; legend(h(1:2),’True DTFT’,’DFT Estimate’,4); set(h(1),’LineWidth’,2.0); subplot(2,1,2); set(h(2),’LineWidth’,1.0); h = plot(w,imag(X),’r’,we,imag(Xe),’k’); ylabel(’Imag X(e^{j\omega})’); set(h(2),’Marker’,’o’); xlim([0 pi]); set(h(2),’MarkerFaceColor’,’k’); box off; set(h(2),’MarkerSize’,3); AxisLines; ylabel(’Imag X(e^{j\omega})’); xlabel(’Frequency (rads per sample)’); xlim([0 pi]); AxisSet(8); box off; print -depsc FFTEstimatePadded; AxisLines; xlabel(’Frequency (rads per sample)’); AxisSet(8); print -depsc FFTEstimate; %============================================================================== % Plot the True Transform \& Estimate %============================================================================== n = 1:16; x = -1*(n>=1 & n<=4) + 1*(n>=13 & n<=16); N = 2^(ceil(log2(2000))); k = 0:N-1; we = (0:N-1)*(2*pi/N); % Frequency of estimates Xe = exp(-j*k*(2*pi/N)*1).*fft(x,N); J. McNames Portland State University ECE 223 FFT Ver. 1.03 19 J. McNames Portland State University ECE 223 FFT Ver. 1.03 20

  6. Some Key Points on Windowing & the FFT • In practice, most DT signals are truncated to a finite duration prior to processing • Mathematically, this is equivalent to multiplying an signal with infinite duration by another signal with finite duration: x [ n ] · w [ n ] • This process is called windowing • Windowing in time is equivalent to convolution in frequency: FT 1 � X (e jω ) ⊛ W (e jω ) � x [ n ] · w [ n ] ⇐ ⇒ 2 π • This causes a blurring of the estimated DTFT • The FFT is a very efficient means of calculating the DTFT of a finite duration DT signal at discrete frequencies • Zero padding can be used to obtain arbitrary resolution • The FFT can also be used to efficiently perform convolution in time (details were not discussed in class) J. McNames Portland State University ECE 223 FFT Ver. 1.03 21

Recommend


More recommend