Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Comparison of a resistor + coil vs a perfect gyrator
import numpy as np
from scipy.signal import freqs
import matplotlib.pyplot as plt
c = 47.0e-9
r1 = 2.2e3
r2 = 100.0e3
a1 = [1.]
b1 = r1 * np.array((1., r2*c))[::-1]
a2 = np.array((1., r1*c))[::-1]
b2 = r1 * np.array((1., r2*c))[::-1]
w1, h1 = freqs(b1, a1, worN=np.logspace(1, 4.2, 10000))
w2, h2 = freqs(b2, a2, worN=np.logspace(1, 4.2, 10000))
plt.semilogx(w1, 20 * np.log10(abs(h1)), label="coil")
plt.semilogx(w2, 20 * np.log10(abs(h2)), label="gyrator")
plt.xlabel('Frequency')
plt.ylabel('Amplitude response [dB]')
plt.legend()
plt.grid()
plt.figure()
plt.semilogx(w1, np.angle(h1), label="coil")
plt.semilogx(w2, np.angle(h2), label="gyrator")
plt.xlabel('Frequency')
plt.ylabel('Angle')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment