Question: 2. (25%, Ch7: FIR Filter Design) Let's write some interesting Python functions that may be beneficial for future usage for designing a FIR filter. We

 2. (25%, Ch7: FIR Filter Design) Let's write some interesting Pythonfunctions that may be beneficial for future usage for designing a FIR

2. (25%, Ch7: FIR Filter Design) Let's write some interesting Python functions that may be beneficial for future usage for designing a FIR filter. We will also be able use these functions to create some simple but amazing FIR filters later in later problems. (1) (15%) As we all know, the absolute and relative (dB) specifications for a lowpass filter are related by 82 Rp = 20 log10 > 0(0) > 0(> 1) 1+81 1- 81 and As -20 log10 1+81 a. Write a Python function to convert absolute specifications 8, and d, into the relative specifications R, and , in dB. The format of the function should be: 1. 2. 3. 4. def delta2db(delta1, delta2): # Converts absolute specs deltal and delta2 into dB specs Rp and As return Rp, As b. (15%) Write a Python function to convert the relative (dB) specifications R, and 4 into the absolute specifications S, and 82. The format of the function should be: 1. def db2delta(Rp, As): 2. # Converts de specs Rp and As into absolute specs delta1 and delta2 3. 4. return delta1, delta2 c. Verify your written functions using the script given below: 1. Rp, As = delta2db(0.01, 0.001) # Rp: 0.1737, As: 60.0864 2. # print(Rp, As) 3. delta1, delta2 = db2delta(0.25, 50) # delta1: 0.0144, delta2: 0.0032 4. # print(deltal, delta2) How to create a simple low-pass filter? A low pass filter is meant to allow low frequencies to pass, but to stop high frequencies. Theoretically, the ideal (i.e., perfect) low-pass filter is the sinc filter. The sinc function is defined as sin(ax) sin c(x) = a. Let's create a Python function to realize a simple low-pass filter. The format of the function should be: 1. 2. 3. 4. 5. 6. 7. def ideal_lp (wc, M): # Ideal LowPass filter computation # hd = ideal impulse response between 0 to M-1 # WC = cutoff frequency in radians # M = length of the ideal filter return hd b. Verify your written functions using the script given, you will get the same plot as provided: 1. hd = ideal_lp(0.55 * np.pi, 21) 2. n = np.arange (21) 3. 4. plt.stem(n, hd) 5. plt.show() 2. (25%, Ch7: FIR Filter Design) Let's write some interesting Python functions that may be beneficial for future usage for designing a FIR filter. We will also be able use these functions to create some simple but amazing FIR filters later in later problems. (1) (15%) As we all know, the absolute and relative (dB) specifications for a lowpass filter are related by 82 Rp = 20 log10 > 0(0) > 0(> 1) 1+81 1- 81 and As -20 log10 1+81 a. Write a Python function to convert absolute specifications 8, and d, into the relative specifications R, and , in dB. The format of the function should be: 1. 2. 3. 4. def delta2db(delta1, delta2): # Converts absolute specs deltal and delta2 into dB specs Rp and As return Rp, As b. (15%) Write a Python function to convert the relative (dB) specifications R, and 4 into the absolute specifications S, and 82. The format of the function should be: 1. def db2delta(Rp, As): 2. # Converts de specs Rp and As into absolute specs delta1 and delta2 3. 4. return delta1, delta2 c. Verify your written functions using the script given below: 1. Rp, As = delta2db(0.01, 0.001) # Rp: 0.1737, As: 60.0864 2. # print(Rp, As) 3. delta1, delta2 = db2delta(0.25, 50) # delta1: 0.0144, delta2: 0.0032 4. # print(deltal, delta2) How to create a simple low-pass filter? A low pass filter is meant to allow low frequencies to pass, but to stop high frequencies. Theoretically, the ideal (i.e., perfect) low-pass filter is the sinc filter. The sinc function is defined as sin(ax) sin c(x) = a. Let's create a Python function to realize a simple low-pass filter. The format of the function should be: 1. 2. 3. 4. 5. 6. 7. def ideal_lp (wc, M): # Ideal LowPass filter computation # hd = ideal impulse response between 0 to M-1 # WC = cutoff frequency in radians # M = length of the ideal filter return hd b. Verify your written functions using the script given, you will get the same plot as provided: 1. hd = ideal_lp(0.55 * np.pi, 21) 2. n = np.arange (21) 3. 4. plt.stem(n, hd) 5. plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!