Complete the code to import the function that computes the poles and zeros of a system.
from scipy.signal import [1] zeros, poles, _ = tf2zpk([1, 0.5], [1, -0.8, 0.15])
The tf2zpk function computes zeros, poles, and gain from numerator and denominator coefficients.
Complete the code to plot the poles and zeros on the complex plane.
import matplotlib.pyplot as plt plt.scatter(zeros.real, zeros.imag, marker='o', label='Zeros') plt.scatter(poles.real, poles.[1], marker='x', label='Poles') plt.xlabel('Real') plt.ylabel('Imaginary') plt.legend() plt.grid(True) plt.title('Pole-Zero Plot') plt.show()
To plot poles on the complex plane, use their imaginary parts with poles.imag.
Fix the error in the code that checks system stability by verifying if all poles are inside the unit circle.
stable = all(abs(p) [1] 1 for p in poles) print('System is stable:', stable)
A discrete-time system is stable if all poles lie strictly inside the unit circle, so their magnitude is less than 1.
Fill both blanks to create a dictionary of poles and zeros with their magnitudes.
magnitudes = { 'zeros': [abs(z) for z in [1]], 'poles': [abs(p) for p in [2]] }We use the variables zeros and poles to get their magnitudes with abs().
Fill all three blanks to filter poles with magnitude greater than 1 and create a list of their angles in radians.
import cmath unstable_poles = [p for p in [1] if abs(p) [2] 1] angles = [[3](p) for p in unstable_poles]
We filter poles with magnitude greater than 1 and use cmath.phase to get their angles.