Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 1-6 >01) R, = -20 1080 1+1 -> 0(0) and A. = -20 10510 14 a. Write a Python function to convert absolute specifications 8 and 8, into the relative specifications R and A, in dB. The format of the function should be: 1. minima def delta2db (deltal, delta2): # Converts absolute specs deltal and delta2 into de specs Rp and As return Rp, As b. (15%) Write a Python function to convert the relative (dB) specifications R, and A, into the absolute specifications 8 and 8. The format of the function should be: 1. 2 def db2delta(Rp, As): # Converts dB specs Rp and As into absolute specs delta1 and delta2 return deltal, 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) # deltal: 0.0144, delta2: 0.0032 4. # print (deltal, delta2) (2) 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 c(x) = sin(ix) a. Let's create a Python function to realize a simple low-pass filter. The format of the function should be: - def ideal_lp(wc, M): # Ideal LowPass filter computation # hd = ideal impulse response between @ 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 1-6 >01) R, = -20 1080 1+1 -> 0(0) and A. = -20 10510 14 a. Write a Python function to convert absolute specifications 8 and 8, into the relative specifications R and A, in dB. The format of the function should be: 1. minima def delta2db (deltal, delta2): # Converts absolute specs deltal and delta2 into de specs Rp and As return Rp, As b. (15%) Write a Python function to convert the relative (dB) specifications R, and A, into the absolute specifications 8 and 8. The format of the function should be: 1. 2 def db2delta(Rp, As): # Converts dB specs Rp and As into absolute specs delta1 and delta2 return deltal, 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) # deltal: 0.0144, delta2: 0.0032 4. # print (deltal, delta2) (2) 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 c(x) = sin(ix) a. Let's create a Python function to realize a simple low-pass filter. The format of the function should be: - def ideal_lp(wc, M): # Ideal LowPass filter computation # hd = ideal impulse response between @ 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started