📖 Scenario: Imagine you are working with a simple digital filter in signal processing. You want to check if this filter is stable by looking at its poles and zeros.In real life, engineers check filter stability to make sure signals don't get distorted or blow up.
🎯 Goal: You will create a dictionary of filter coefficients, set a stability threshold, find poles and zeros, and finally check if the filter is stable.
📋 What You'll Learn
Create a dictionary called filter_coeffs with keys 'b' and 'a' for numerator and denominator coefficients.
Create a variable called stability_radius and set it to 1.
Use scipy.signal.tf2zpk to find poles and zeros from filter_coeffs['b'] and filter_coeffs['a'].
Check if all poles have absolute value less than stability_radius to determine stability.
Print poles, zeros, and is_stable.
💡 Why This Matters
🌍 Real World
Engineers use pole-zero analysis to check if digital filters will behave well and not cause signal distortion or instability.
💼 Career
Understanding filter stability is important for roles in signal processing, audio engineering, communications, and control systems.
Progress0 / 4 steps
1
Create filter coefficients dictionary
Create a dictionary called filter_coeffs with keys 'b' and 'a'. Set filter_coeffs['b'] to the list [0.0675, 0.1349, 0.0675] and filter_coeffs['a'] to the list [1.0, -1.1430, 0.4128].
Signal Processing
Hint
Use a dictionary with keys 'b' and 'a' and assign the exact lists as values.
2
Set stability radius
Create a variable called stability_radius and set it to 1.
Signal Processing
Hint
Just assign the number 1 to the variable stability_radius.
3
Find poles and zeros
Import scipy.signal and use scipy.signal.tf2zpk with filter_coeffs['b'] and filter_coeffs['a'] to find zeros, poles, and gain. Then create a variable is_stable that is True if all poles have absolute value less than stability_radius, otherwise False.
Signal Processing
Hint
Use tf2zpk to get zeros, poles, gain. Use a generator expression with all() to check poles.
4
Print poles, zeros, and stability
Print the variables poles, zeros, and is_stable each on a separate line.
Signal Processing
Hint
Use three print statements to show poles, zeros, and stability result.
Practice
(1/5)
1. What does the location of poles inside the unit circle on a pole-zero plot indicate about a system's stability?
easy
A. The system is stable
B. The system is unstable
C. The system is marginally stable
D. The system has no poles
Solution
Step 1: Understand pole location and stability
Poles inside the unit circle mean the system's response decays over time.
Step 2: Relate pole location to system behavior
Since poles are inside the unit circle, the system output will not grow unbounded.
Final Answer:
The system is stable -> Option A
Quick Check:
Poles inside unit circle = stable system [OK]
Hint: Poles inside unit circle mean stability [OK]
Common Mistakes:
Confusing poles inside with outside the unit circle
Thinking zeros affect stability directly
Ignoring the unit circle boundary
2. Which of the following is the correct Python syntax to plot poles and zeros using matplotlib for a system with poles at [0.5+0.5j, 0.5-0.5j] and zeros at [0.8]?
D. plt.plot([0.5, 0.5], [0.5, -0.5], 'bx'); plt.plot([0.8], [0], 'ro')
Solution
Step 1: Identify correct markers for poles and zeros
Poles are usually marked with 'x' in red, zeros with 'o' in blue.
Step 2: Match syntax with matplotlib scatter function
plt.scatter([0.5, 0.5], [0.5, -0.5], marker='x', color='r'); plt.scatter([0.8], [0], marker='o', color='b') uses plt.scatter with correct markers and colors for poles and zeros.
Correct markers and colors for poles and zeros [OK]
Hint: Poles = red 'x', zeros = blue 'o' in plots [OK]
Common Mistakes:
Swapping markers for poles and zeros
Using plt.plot with wrong format strings
Plotting zeros at wrong coordinates
3. Given the poles at [0.9, 1.1] and zeros at [0.5], what will be the stability status of the system?
medium
A. Stable because one pole is inside the unit circle
B. Stable because zeros are inside the unit circle
C. Marginally stable because poles are on the unit circle
D. Unstable because one pole is outside the unit circle
Solution
Step 1: Check each pole's location relative to the unit circle
One pole is at 0.9 (inside), the other at 1.1 (outside) the unit circle.
Step 2: Determine stability from pole locations
Since a pole lies outside the unit circle, the system is unstable regardless of zeros.
Final Answer:
Unstable because one pole is outside the unit circle -> Option D
Quick Check:
Any pole outside unit circle = unstable [OK]
Hint: Any pole outside unit circle means unstable system [OK]
Common Mistakes:
Ignoring poles outside the unit circle
Confusing zeros with poles for stability
Assuming zeros affect stability directly
4. The following Python code attempts to plot poles and zeros but produces an error. What is the error and how to fix it?
import matplotlib.pyplot as plt
poles = [0.7+0.7j, 0.7-0.7j]
zeros = [0.9]
plt.scatter(poles.real, poles.imag, marker='x', color='r')
plt.scatter(zeros.real, zeros.imag, marker='o', color='b')
plt.show()
medium
A. Error because marker symbols are incorrect
B. Error because poles and zeros are lists, need numpy arrays for .real and .imag
C. Error because plt.show() is missing
D. No error, code runs fine
Solution
Step 1: Identify data types of poles and zeros
Poles and zeros are Python lists of complex numbers, which do not support .real or .imag attributes directly.
Step 2: Fix by converting lists to numpy arrays
Convert poles and zeros to numpy arrays to access .real and .imag properties without error.
Final Answer:
Error because poles and zeros are lists, need numpy arrays for .real and .imag -> Option B
Quick Check:
Lists lack .real/.imag; use numpy arrays [OK]
Hint: Use numpy arrays for complex .real and .imag access [OK]
Common Mistakes:
Trying to access .real on Python lists
Ignoring missing plt.show()
Using wrong marker symbols
5. You have a discrete-time system with poles at [0.6, 0.8*1j, -0.8*1j] and zeros at [0.9]. You want to improve stability by moving poles closer to the origin without changing zeros. Which pole movement will make the system more stable?
hard
A. Move poles to [0.6, 0.8j, -0.8j] (no change)
B. Move poles to [1.1, 0.9j, -0.9j]
C. Move poles to [0.4, 0.5j, -0.5j]
D. Move poles to [0.7, 0.85j, -0.85j]
Solution
Step 1: Understand stability and pole radius
Poles closer to origin (smaller magnitude) mean faster decay and better stability.
Step 2: Compare given pole movements
Move poles to [0.4, 0.5j, -0.5j] moves poles closer to origin (0.4 and 0.5j), reducing magnitude from original values.
Step 3: Confirm other options increase or keep magnitude same
Options B and C move poles farther or slightly farther from origin, reducing stability; A is no change.
Final Answer:
Move poles to [0.4, 0.5j, -0.5j] -> Option C
Quick Check:
Smaller pole radius = better stability [OK]
Hint: Move poles closer to origin to improve stability [OK]
Common Mistakes:
Moving poles outside unit circle
Changing zeros instead of poles
Not reducing pole magnitude
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.