ECE 3640 Katelyn Johnson A01984215 April 23, 2019 HW10 1. This problem explores the design a symmetric real-valued linear phase FIR bandpass filter that meets the following specifications. • Design this filter using the window technique using the best window from the set (rectangular, Bartlett, Hann, Hamming, Blackman). Indicate which window shape you used. • Design this filter using the window technique using the Kaiser window. Indicate the Kaiser window parameters (β and M). • Using FDATool in Matlab, design this filter using equiripple design method. Make a table with one row for each filter you designed (window, Kaiser, equiripple). The table should have a column for the following parameters: length, order, group delay, type (I, II, III, or IV), and window parameters. Answer: The length of the Hann filter was increased to make the filter a type I. Hann Kaiser Equiripple Length 63 47 37 Order 62 46 36 Group Delay 31 23 18 Type I I I Window Parameters N/A B = 3.3953 N/A For each filter you design, turn in plots of the impulse response, magnitude response (linear and dB), and phase response. The frequency domain plots should show response over the interval − 12 ≤ f ≤ 21 . Also include a pole-zero plot. Plots for the Hann filter 1 ECE 3640 Plots for the Kaiser filter 2 ECE 3640 Plots for the Equiripple filter 3 ECE 3640 Matlab Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 4 %Hann L = 63; M = L−1; n = [ 0 :M] ’ ; a = M/ 2 ; w = hann ( L ) ; h1 = s i n ( 2 ∗ p i ∗ 0 . 3 5 ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h1 ( i n d ) = 2 ∗ 0 . 3 5 ; h2 = s i n ( 2 ∗ p i ∗ . 1 5 ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h2 ( i n d ) = 2 ∗ 0 . 1 5 ; h = h1−h2 ; H = f f t s h i f t ( f f t ( h . ∗ w , N) ) ; figure (1) ; stem ( n , h . ∗w) ; t i t l e ( ’ Impulse Response ’ ) ; N = 2ˆ16; f = [−N / 2 : ( N−1) / 2 ] /N ; p r i n t −dpng 1 h i m p u l s e . png figure (2) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s (H) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 1hmagdB . png figure (3) ; p l o t ( f , a b s (H) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 1hmagL . png figure (4) ; p l o t ( f , unwrap ( a n g l e (H) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 1 h p h a s e . png figure (5) ; z p l a n e ( ( h . ∗w) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 1 h z e r o . png %K a i s e r M = 46; L = M+1; n = [ 0 :M] ’ ; beta = 3 . 3 9 5 3 ; a = M/ 2 ; w = k a i s e r (L , beta ) ; h1 = s i n ( 2 ∗ p i ∗ 0 . 3 5 ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h1 ( i n d ) = 2 ∗ 0 . 3 5 ; h2 = s i n ( 2 ∗ p i ∗ . 1 5 ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h2 ( i n d ) = 2 ∗ 0 . 1 5 ; h = h1−h2 ; H = f f t s h i f t ( f f t ( h . ∗ w , N) ) ; figure (6) ; stem ( n , h . ∗w) ; t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 1 k i m p u l s e . png figure (7) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s ( f f t ( h . ∗ w , N) ) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 1kmagdB . png figure (8) ; p l o t ( f , a b s ( f f t ( h . ∗ w , N) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 1kmagL . png figure (9) ; p l o t ( f , unwrap ( a n g l e ( f f t ( h . ∗ w , N) ) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 1 k p h a s e . png figure (10) ; z p l a n e ( ( h . ∗w) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 1 k z e r o . png %E q u i r i p p l e figure (11) ; stem ( [ 0 : l e n g t h ( e q u i ) −1 ] , e q u i ) ; ECE 3640 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 1 e i m p u l s e . png figure (12) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ) ; t i t l e ( ’ Ma gni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 1emagdB . png figure (13) ; p l o t ( f , a b s ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ; t i t l e ( ’ Ma gni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 1emagL . png figure (14) ; %i s t h i s how t h e p h a s e s h o u l d be o r s h o u l d i t p l o t ( f , unwrap ( a n g l e ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 1 e p h a s e . png be the zero phase ? figure (15) ; zplane (( equi ) ,1) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 1 e z e r o . png 2. This problem explores designing a lowpass filter with a very narrow transition band that achieves the following specifications: Ap = 0.1 dB ripple in the passband (0 ≤ f ≤ .24) and As = 60 dB suppression in the stopband (.26 ≤ f ≤ .5). • Design this filter using the window technique using the best window from the set (rectangular, Bartlett, Hann, Hamming, Blackman). Indicate which window shape you used. • Design this filter using the window technique using the Kaiser window. Indicate the Kaiser window parameters (β and M). • Using FDATool in Matlab, design this filter using equiripple design method. Make a table with one row for each filter you designed (window, Kaiser, equiripple). The table should have a column for the following parameters: length, order, group delay, type (I, II, III, or IV), and window parameters. Blackman Kaiser Equiripple Length 275 183 167 Order 274 182 166 Group Delay 137 91 83 Type I I I Window Parameters N/A B = 5.65326 N/A For each filter you design, turn in plots of the impulse response, magnitude response (linear and dB), and phase response. The frequency domain plots should show response over the interval − 12 ≤ f ≤ 21 . Also include a pole-zero plot. Plots for the Blackman filter 5 ECE 3640 Plots for the Kaiser filter 6 ECE 3640 Plots for the Equiripple filter 7 ECE 3640 Matlab Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 8 %Blackman L = 275; M = L−1; n = [ 0 :M] ’ ; a = M/ 2 ; fc = .25 w = blackman ( L ) ; h = s i n ( 2 ∗ p i ∗ f c ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h ( i n d ) = 2∗ f c ; H = f f t s h i f t ( f f t ( h . ∗ w , N) ) ; figure (1) ; stem ( n , h . ∗w) ; t i t l e ( ’ Impulse Response ’ ) ; N = 2ˆ16; f = [−N / 2 : ( N−1) / 2 ] /N ; p r i n t −dpng 2 h i m p u l s e . png figure (2) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s (H) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 2hmagdB . png figure (3) ; p l o t ( f , a b s (H) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 2hmagL . png figure (4) ; p l o t ( f , unwrap ( a n g l e (H) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 2 h p h a s e . png figure (5) ; z p l a n e ( ( h . ∗w) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 2 h z e r o . png %K a i s e r M = 182; L = M+1; n = [ 0 :M] ’ ; beta = 5 . 6 5 3 2 6 ; a = M/ 2 ; w = k a i s e r (L , beta ) ; h = s i n ( 2 ∗ p i ∗ f c ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h ( i n d ) = 2∗ f c ; H = f f t s h i f t ( f f t ( h . ∗ w , N) ) ; figure (6) ; stem ( n , h . ∗w) ; t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 2 k i m p u l s e . png figure (7) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s (H) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 2kmagdB . png figure (8) ; p l o t ( f , a b s (H) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 2kmagL . png figure (9) ; p l o t ( f , unwrap ( a n g l e (H) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 2 k p h a s e . png figure (10) ; z p l a n e ( ( h . ∗w) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 2 k z e r o . png %E q u i r i p p l e figure (11) ; stem ( [ 0 : l e n g t h ( e q u i ) −1 ] , e q u i ) ; t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 2 e i m p u l s e . png figure (12) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; ECE 3640 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 y l a b e l ( ’ Ma gn itu de ’ ) ; p r i n t −dpng 2emagdB . png figure (13) ; p l o t ( f , a b s ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ; t i t l e ( ’ Ma gni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 2emagL . png figure (14) ; p l o t ( f , unwrap ( a n g l e ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 2 e p h a s e . png figure (15) ; zplane (( equi ) ,1) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 2 e z e r o . png 3. This problem explores designing a lowpass filter for sample rate conversion using the system depicted in Fig. 4.29 (b) in the textbook (page 191) in which the upsampling factor is L = 3 and the downsampling factor is M = 4 . (Note: the L and M parameters in Fig. 4.29 are the up and down sampling factors. We have also used L and M to denote the length L and order M of FIR filters.) The maximum frequency in the signal x[n] is fmax,x = 31 . Design the lowpass filter to have Ap = 0.1 dB of ripple in the pass band and As = 60 dB of attenuation in the stopband. Use your knowledge of upsampling and downsampling to determine the passband and stopband edge frequencies, fp and fs . What are fp and fs ? Answer: fp = 19 and fs = 29 . • Design this filter using the window technique using the best window from the set (rectangular, Bartlett, Hann, Hamming, Blackman). Indicate which window shape you used. • Design this filter using the window technique using the Kaiser window. Indicate the Kaiser window parameters (β and M). • Using FDATool in Matlab, design this filter using equiripple design method. Make a table with one row for each filter you designed (window, Kaiser, equiripple). The table should have a column for the following parameters: length, order, group delay, type (I, II, III, or IV), and window parameters. Answer: The length of the Blackman filter was increased to make the filter a type I. Blackman Kaiser Equiripple Length 51 35 33 Order 50 34 32 Group Delay 25 17 16 Type I I I Window Parameters N/A B = 5.65326 N/A For each filter you design, turn in plots of the impulse response, magnitude response (linear and dB), and phase response. The frequency domain plots should show response over the interval − 12 ≤ f ≤ 21 . Also include a pole-zero plot. Plots for the Blackman filter 9 ECE 3640 Plots for the Kaiser filter 10 ECE 3640 Plots for the Equiripple filter 11 ECE 3640 Matlab Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 12 %Blackman L = 51; M = L−1; n = [ 0 :M] ’ ; a = M/ 2 ; fc = 3/18; w = blackman ( L ) ; h = s i n ( 2 ∗ p i ∗ f c ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h ( i n d ) = 2∗ f c ; H = f f t s h i f t ( f f t ( h . ∗ w , N) ) ; figure (1) ; stem ( n , h . ∗w) ; t i t l e ( ’ Impulse Response ’ ) ; N = 2ˆ16; f = [−N / 2 : ( N−1) / 2 ] /N ; p r i n t −dpng 3 h i m p u l s e . png figure (2) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s (H) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 3hmagdB . png figure (3) ; p l o t ( f , a b s (H) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 3hmagL . png figure (4) ; p l o t ( f , unwrap ( a n g l e (H) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 3 h p h a s e . png figure (5) ; z p l a n e ( ( h . ∗w) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 3 h z e r o . png %K a i s e r M = 34; L = M+1; n = [ 0 :M] ’ ; beta = 5 . 6 5 3 2 6 ; a = M/ 2 ; w = k a i s e r (L , beta ) ; h = s i n ( 2 ∗ p i ∗ f c ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h ( i n d ) = 2∗ f c ; H = f f t s h i f t ( f f t ( h . ∗ w , N) ) ; figure (6) ; stem ( n , h . ∗w) ; t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 3 k i m p u l s e . png figure (7) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s (H) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 3kmagdB . png figure (8) ; p l o t ( f , a b s (H) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 3kmagL . png figure (9) ; p l o t ( f , unwrap ( a n g l e (H) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 3 k p h a s e . png figure (10) ; z p l a n e ( ( h . ∗w) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 3 k z e r o . png %E q u i r i p p l e figure (11) ; stem ( [ 0 : l e n g t h ( e q u i ) −1 ] , e q u i ) ; t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 3 e i m p u l s e . png figure (12) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; ECE 3640 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 y l a b e l ( ’ Ma gn itu de ’ ) ; p r i n t −dpng 3emagdB . png figure (13) ; p l o t ( f , a b s ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ; t i t l e ( ’ Ma gni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 3emagL . png figure (14) ; p l o t ( f , unwrap ( a n g l e ( f f t s h i f t ( f f t ( e q u i , N) ) ) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 3 e p h a s e . png figure (15) ; zplane (( equi ) ,1) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 3 e z e r o . png 4. Suppose you would like to boost by a factor of 4 the low frequencies of an audio signal between the range of 0 ≤ |F | ≤ 150 Hz and leave the scale of frequencies above 300 Hz unchanged. This type of filter has two passbands and no stopband. It is called a shelving filter. The transition band extends from 150 Hz to 300 Hz. You plan to perform this processing using the system depicted in Fig. 4.10 of the textbook (page 167) using a sample rate of T1 = Fs = 20k samples/second. Convert this information to a specification for a discrete-time filter and design a linear phase filter to meet this spec. Require your filter to limit deviations from the desired response to δ = 0.01 in both pass bands. • Design this filter using the window technique using the best window from the set (rectangular, Bartlett, Hann, Hamming, Blackman). Indicate which window shape you used. • Design this filter using the window technique using the Kaiser window. Indicate the Kaiser window parameters (β and M). • Using FDATool in Matlab, design this filter using equiripple design method. Make a table with one row for each filter you designed (window, Kaiser, equiripple). The table should have a column for the following parameters: length, order, group delay, type (I, II, III, or IV), and window parameters. Answer: The length of the Hann filter was increased to make the filter a type I. Hann Kaiser Equiripple Length 415 299 281 Order 414 298 280 Group Delay 207 149 140 Type I I I Window Parameters N/A B = 3.39532 N/A For each filter you design, turn in plots of the impulse response, magnitude response (linear and dB), and phase response. The frequency domain plots should show response over the interval − 12 ≤ f ≤ 21 . Also include a pole-zero plot. Plots for the Blackman filter 13 ECE 3640 Plots for the Kaiser filter 14 ECE 3640 Plots for the Equiripple filter 15 ECE 3640 Matlab Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 16 %Hann L = 415; M = L−1; n = [ 0 :M] ’ ; a = M/ 2 ; fc = .01125; w = hann ( L ) ; h = s i n ( 2 ∗ p i ∗ f c ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h ( i n d ) = 2∗ f c ; Hw = 3∗ h . ∗w ; Hw( a +1) = Hw( a +1) +1; H = f f t s h i f t ( f f t (Hw, N) ) ; figure (1) ; stem ( n , Hw) ; t i t l e ( ’ Impulse Response ’ ) ; N = 2ˆ16; f = [−N / 2 : ( N−1) / 2 ] /N ; p r i n t −dpng 4 h i m p u l s e . png figure (2) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s (H) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 4hmagdB . png figure (3) ; p l o t ( f , a b s (H) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gni tu de ’ ) ; g r i d on ; p r i n t −dpng 4hmagL . png figure (4) ; p l o t ( f , unwrap ( a n g l e (H) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 4 h p h a s e . png figure (5) ; z p l a n e ( (Hw) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 4 h z e r o . png %K a i s e r M = 298; L = M+1; n = [ 0 :M] ’ ; beta = 3 . 3 9 5 3 2 ; a = M/ 2 ; w = k a i s e r (L , beta ) ; h = s i n ( 2 ∗ p i ∗ f c ∗ ( n−a ) ) . / ( p i ∗ ( n−a ) ) ; i n d = f i n d ( n−a==0) ; h ( i n d ) = 2∗ f c ; Hw = 3∗ h . ∗w ; Hw( a +1) = Hw( a +1) +1; H = f f t s h i f t ( f f t (Hw, N) ) ; figure (6) ; stem ( n , Hw) ; t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 4 k i m p u l s e . png figure (7) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s (H) ) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 4kmagdB . png figure (8) ; p l o t ( f , a b s (H) ) ; t i t l e ( ’ Mag ni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 4kmagL . png figure (9) ; p l o t ( f , unwrap ( a n g l e (H) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 4 k p h a s e . png figure (10) ; z p l a n e ( (Hw) . ’ , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 4 k z e r o . png %E q u i r i p p l e Hw = 3∗ e q u i ; len = length ( equi ) ; a = ( l e n −1) / 2 ; Hw( a +1) = Hw( a +1) +1; ECE 3640 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 figure (11) ; stem ( [ 0 : l e n g t h ( e q u i ) −1 ] ,Hw) ; t i t l e ( ’ Impulse Response ’ ) ; p r i n t −dpng 4 e i m p u l s e . png figure (12) ; p l o t ( f , 2 0 ∗ l o g 1 0 ( a b s ( f f t s h i f t ( f f t (Hw, N) ) ) ) ) ; t i t l e ( ’ Ma gni tu de R e s p o n s e dB ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; p r i n t −dpng 4emagdB . png figure (13) ; p l o t ( f , a b s ( f f t s h i f t ( f f t (Hw, N) ) ) ) ; t i t l e ( ’ Ma gni tu de R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Ma gn itu de ’ ) ; g r i d on ; p r i n t −dpng 4emagL . png figure (14) ; p l o t ( f , unwrap ( a n g l e ( f f t s h i f t ( f f t (Hw, N) ) ) ) ) ; t i t l e ( ’ Phase R e s p o n s e ’ ) ; x l a b e l ( ’ F r e q u e n c y [ Hz ] ’ ) ; y l a b e l ( ’ Amplitude ’ ) ; g r i d on ; p r i n t −dpng 4 e p h a s e . png figure (15) ; z p l a n e ( (Hw) , 1 ) ; a x i s ([ −1 1 −1 1 ] ∗ 2 ) ; t i t l e ( ’ Zero Pole Plot ’ ) ; p r i n t −dpng 4 e z e r o . png 5. After working the previous 4 problems, summarize your observations about the best filter design method to use if the goal is to minimize the filter length. Answer: The equiripple filter is the best method if the goal is to minimize the filter length. the equiripple instance of each problem had a consistently shorter length. 17