I'm working with some relatively simple algebraic expressions in python and wondered if there's a better way of plotting algebraic expressions than what I'm currently doing:
I have the equation of a notch filter (below image - left side from a book; the right side graph is the fig generated by my code), and so far my code works though is crude.
Is there a better way of plotting the magnitude? As shown the constants are; R = 50.0, C = 470e-12, L = 54e-6, and the desired frequency range is from 0 to 2MHz.
import matplotlib.pyplot as plt
import numpy as np
import math
R = 50.0
C = 470e-12
L = 54e-6
FREQ = []
DATA = []
for i in range(1, 200):
f = i*10000.0
w = 2*np.pi*f
Ztop = w*L - 1.0/(w*C)
Zbot = math.sqrt( (math.pow(R,2) + math.pow((w*L) -(1.0/(w*C)),2)) )
Zout = abs(Ztop / Zbot)
FREQ.append( f/1e6 )
DATA.append( Zout )
plt.figure(1)
plt.plot(FREQ,DATA, '-k')
plt.xlabel('Frequency (MHz)')
plt.ylabel('Mag.')
plt.grid()
plt.show()