FIR Filters and Convolution Example An FIR filter has impulse response h n = – 2 n + 3 n – 1 + n – 2 The input to the filter, x n , is 4 – n, 0 n 3 xn = otherwise 0, • Find the filter output y n Expected output range [0+0, 3+2] = [0,5] sum of products formed between h[k] and x[n-k] inside red box. h[k] n=0 n=1 ... 1 y[n] 0 4 3 2 1 0 0 0 ... ... 0 0 4 3 2 1 0 0 0 ... ... 0 0 4 3 2 1 0 0 0 ... ... 0 0 4 3 2 1 0 0 0 ... ... 0 0 4 3 2 1 0 0 0 ... ... 0 0 4 3 2 1 0 0 0 ... 4 ... 0 0 4 3 2 1 0 0 0 0 n=3 n=4 n=5 n=6 n= 3 0 n=2 n=7 -2 -2 -1 1 3 15 Flipped and shifted: x[n-k] Outputs for n < 0 and n > 5 are all 0 n= n= Start at n=0 >> filter([-2 3 1],1,[1 2 3 4 0 0]) ans = -2 -1 1 3 15 4 ECE 2610 Example Page–1 An FIR filter has impulse response h n = 1 1 2 2 n = 0 The input to the filter is x n = 4 – 2 2 n = 0 • Find the filter output y n sum of products formed between h[k] and x[n-k] inside red box. h[k] 0 Expected output range [0+0, 3+2] = [0,5] 0 0 0 0 0 1 1 2 2 0 0 0 0 0 0 y[n] n=0 0 0 0 0 2 -2 4 0 0 0 0 0 0 0 0 0 4 n=1 0 0 0 0 0 2 -2 4 0 0 0 0 0 0 0 0 2 n=2 0 0 0 0 0 0 2 -2 4 0 0 0 0 0 0 0 8 n=3 0 0 0 0 0 0 0 2 -2 4 0 0 0 0 0 0 6 n=4 0 0 0 0 0 0 0 0 2 -2 4 0 0 0 0 0 0 n=5 0 0 0 0 0 0 0 0 0 2 -2 4 0 0 0 0 4 n=6 0 0 0 0 0 0 0 0 0 0 2 -2 4 0 0 0 0 n=7 0 0 0 0 0 0 0 0 0 0 0 2 -2 4 0 0 0 n=8 0 0 0 0 0 0 0 0 0 0 0 0 2 -2 4 0 0 n=9 n =10 Flipped and shifted: x[n-k] Outputs for n < 0 and n > 5 are all 0 n = 11 n =12 n =13 MATLAB Check ECE 2610 Example >> filter([1 1 2 2],1,[4 -2 2 0 0 0 0]) ans = 4 2 8 6 0 4 0 n=0 n=5 Page–2