0
0
Signal Processingdata~10 mins

Transfer function H(z) in Signal Processing - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the transfer function H(z) using numerator and denominator coefficients.

Signal Processing
from scipy.signal import TransferFunction
num = [1, -0.5]
den = [1, -0.9]
H = TransferFunction([1], den, dt=1)
Drag options to blanks, or click blank then click option'
Aden
B[0.5, 1]
C[1, 0]
Dnum
Attempts:
3 left
💡 Hint
Common Mistakes
Using denominator coefficients instead of numerator.
Passing a wrong list of coefficients.
2fill in blank
medium

Complete the code to compute the frequency response of H(z) at 512 points.

Signal Processing
from scipy.signal import freqz
w, h = freqz(H.num, H.den, worN=[1])
Drag options to blanks, or click blank then click option'
A1024
B128
C512
D256
Attempts:
3 left
💡 Hint
Common Mistakes
Using too few points leading to rough plots.
Using a non-integer or invalid value.
3fill in blank
hard

Fix the error in the code to correctly calculate the magnitude response in decibels.

Signal Processing
import numpy as np
magnitude_db = 20 * np.log10([1])
Drag options to blanks, or click blank then click option'
Aabs(h)
Bh
Cnp.abs(h)**2
Dnp.log10(h)
Attempts:
3 left
💡 Hint
Common Mistakes
Using h directly without absolute value.
Squaring magnitude before log10 incorrectly.
4fill in blank
hard

Fill both blanks to create a dictionary of frequency response with frequency in Hz and magnitude in dB.

Signal Processing
freq_response = [1]: w * [2] / (2 * np.pi) for w, mag in zip(w, magnitude_db)
Drag options to blanks, or click blank then click option'
A{'frequency_hz'
Bfs
C1
Dnp.pi
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong dictionary key names.
Incorrect frequency scaling factor.
5fill in blank
hard

Fill all three blanks to filter a signal x using the transfer function H and store the output in y.

Signal Processing
from scipy.signal import lfilter
y = lfilter([1], [2], [3])
Drag options to blanks, or click blank then click option'
AH.num
BH.den
Cx
DH
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the transfer function object instead of coefficients.
Swapping numerator and denominator coefficients.