import numpy
import matplotlib.pyplot as p
import lab6
from lab2_3 import unit_sample_response
from lab6_1 import freq_res_usr
# compute coefficients for a difference equation with
# a pair of complex conjugate poles at the specified
# frequency and with a scale factor of r.
def pole_to_coeffs(pole_freq,r):
pass # your code here
# use the differential equation solver to convert
# diffeq coefficients into a unit-sample response
def pole_to_usr(pole_freq,r):
ycoeffs = pole_to_coeffs(pole_freq,r)
xcoeffs = [1.0] + [0.0]*(len(ycoeffs) - 1)
channel = lab6.de_solver(ycoeffs,xcoeffs)
return unit_sample_response(channel)
if __name__ == '__main__':
# get unit-sample response for filter with a pole at pi/2
pole_freq = numpy.pi/2
r = 0.98
usr_pole = pole_to_usr(pole_freq,r)
# plot the frequency response
omega_pole, mag_hejw_pole = freq_res_usr(usr_pole)
lab6.plot_freq_response(omega_pole,mag_hejw_pole,
'pole filter @ $\Omega=%3.2g$, r=%3.2g' % (pole_freq,r))
p.show()