Lab 3: The FFT and Digital Filtering Slides prepared by: Chun-Te (Randy) Chu
Lab 3: The FFT and Digital Filtering Assignment 1 Assignment 2 Assignment 3 Assignment 4 Assignment 5
What you will learn in this lab Process the discrete time signal in requency domain by using MATLAB. Horizontal axis: time (sec) Horizontal axis: requency (Hz, radian)
Assignment 1: MATLAB unction FFT 1. MATLAB command : t (Fast Fourier Transorm) It computes Discrete Fourier Transorm (DFT) o a sequence eiciently. y = t(x); Magnitude abs(y) Phase angle(y) Check help or more details 2. MATLAB command : tshit Change t output range (in requency) z = tshit(y); Why do we need shit?
Assignment 1: MATLAB unction FFT The t outputs a sequence in the range 0 ω 2π tshit 0 2 0 w1 = linspace(0, 2*pi, N); plot(w1, abs(y)) w2 = linspace(-pi, pi, N); plot(w2, abs(z)) But it is more natural to plot in the range -π ω π Then the DC component is in the middle o the spectrum
k N N k k X 2 1 0 ~ ], [ DFT: ] [ ]) [ ( ] [ ]) [ ( ] [ ] [ ] [ ] [ ] [ * * 1 0 2 1 0 ) ( 2 1 0 2 k X k X k N X k X e n x e n x k N X e n x k X N n kn N N n n k N N N n kn N So the magnitude plot is symmetric around w=pi
DFT: X[ k], k 0 ~ N 1 2 k N Which one has higher requency? 2 2 1. cos(( ) n) v. s. cos(( 3) n) 8 8 2 2 2. cos(( ) n) v. s. cos(( 7) n) 8 8 2 2 3. cos(( 3) n) v. s. cos(( 7) n) 8 8
Assignment 1: MATLAB unction FFT Short summary 1. Frequency components are symmetric with respect to 2. Highest requency in radian o discrete time signal is, not 2
Assignment 1: MATLAB unction FFT Frequency in Hz ( ) x[ n] 1 cos(2 n) 0.25 or Given is the requency in Hz? and normalized requency 0.5 normalized requency ( ), what x( t) x[ n] e. g. 1 cos(2t) 1 cos(2 ( nt T Sampling s 10 4 s s period 2500 T s or 10, 5000 Hz is normalized in )) 1 cos(2n) 4 0.25 Hz requency or 0.5 requency in Hz sampling requency
Assignment 1: MATLAB unction FFT Normalized requency and requency in radian ) ( s n n n x 2 2 ) cos( 1 ) cos(2 1 ] [ 2 1 2 1 2 2 2 0 1 0 0 s s s ater tshit() ) (
Summary or assignment 1 Use = 0.25 and 0.5 Plot magnitude o (1) unshited DFT, (2) shited DFT; both in radians. Plot magnitude o (3) shited DFT in Hz ( 0 w 2 ) ( w ) s 2 Please indicate which one you are plotting and the requency axis as well. You can use subplot to show dierent plots in the same window. Total 6 images Answer the questions in the lab document. (The text with underline) 2 ( s )
Assignment 2: Frequency Shiting x 3 [n]=sinc( 1 (n-32)) cos(2π 2 n), where 1 = 0.15, 2 = 0.2, n= 0 ~ 255 x3 = sinc(1*(n-32)).*cos(2*pi*2*n); y3 = tshit(t(x3)); 4 FFT Result: 3.5 3 Magnitude o y3 2.5 2 1.5 1 0.5 0-0.5-0.4-0.3-0.2-0.1 0 0.1 0.2 0.3 0.4 0.5 w
Assignment 2: Frequency Shiting 1. Important Concept : convolution property Suppose e[n], g[n] are two the discrete signal E[ω], G[ω] are FFT results or e[n] and g[n] FFT 1 e[ n] g[ n] E[ ] G[ ] 2 2. i e[n] is the sinc unction E[ω] will be a rect. unction
Assignment 2: Frequency Shiting 3. I g[n] is the cosine unction G[ω] will be impulse signal pairs From 1~3 above, we can know that the tshit(t(x3)) can be viewed as E[ ] [ M ] E[ ( M ])
Summary or assignment 2 Turn in the magnitude and phase plots only or (d) x4[n]. The requency range is in 0.5 0.5 You can use subplot to show dierent plots in the same window. Total 2 images Normalized requency Answer the questions in the lab document. (The text with underline)
Assignment 3: FIR Digital Filters FIR: A ilter with Finite Impulse Response b_lowir = ir1(ilter_order, cut-o_req); The cut-o_req is the requency in radian () normalized with respect to e.g. i is 0.3 ; what will be? 0 1 0 Use revalz01() to analyze the system revalz01(b_lowir, 1 ) Only two inputs are necessary. The 2 nd input or revalz01 should be set as 1 here.
Assignment 3: FIR Digital Filters Ex: order o 5 with cuto requency o b_lowir = ir1(5, 0.7); revalz01(b_lowir, 1 ); 0.7
Summary or assignment 3 Turn in the revalz01 plot.
Assignment 4: IIR Digital Filters IIR: A ilter with Ininite Impulse Response [b_lowbutt, a_lowbutt] = butter(ilter_order, cut-o_req); revalz01(b_lowbutt, a_lowbutt );
Summary or assignment 4 Turn in the revalz01 plot. Answer the questions in the lab document. (The text with underline)
Assignment 5: Filter Implementation Matlab Command: ilter x[n] is the input signal: u[n]-u[n-20] with 40 zeros appended. So the total length is 60. y_ir = ilter(b_lowir, 1, x); y_butt = ilter(b_lowbutt, a_lowbutt, x);
Summary or assignment 5 Turn in the plots o (1) input signal x (2) output y_ir (3) output y_butt You can use subplot to show dierent plots in the same window. Total 3 images ater appending zeros Answer the questions in the lab document. (The text with underline)
More About Lab 3 For assignment 1, the 2 nd and 3 rd plots should be almost the same. The dierence between them is the horizontal axis. Because they have dierent units in the horizontal axis, the labeled values are dierent, too. You need to ollow the requirement in the slides, such as indicating clearly and correctly the horizontal axis. The main reason that we want to label the horizontal axis in dierent units is because it is sometimes easy to observe in some speciic unit.
More About Lab 3 I you want to discuss i the peak locations make sense, you can try to ind out what is the result ater you transorm the input signal into requency domain. You can derive by your hand with the deinition o Fourier transorm or look up the transorm pair table in the text book. Ater you get the result, you will see where should the peaks be.
More About Lab 3 I you want to perorm N point FFT to input x[n], you just add an extra input N to the command t. t(x, N) In this lab, either you speciy the N or you don t is ine or us. I you don t speciy, it will automatically take the length o the x[n] as deault N.
More About Lab 3 (i) Please see clearly the questions mentioned in the documents. You need to answer all the questions in order to get the ull credit. (ii) Please read the slides and document careully. You need to ollow the guidelines in the slides. (iv) There is no need to submit the code. You need to turn in the hard copy report in the lab session on the due date.