1 # 7_12.py 2 3 import numpy as np 4 import matplotlib.pyplot as plt 5 6 w = np.linspace(-np.pi, np.pi, 1000) 7 h = 1 - np.exp(-1j * 5 * w) 8 9 fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8)) 10 11 # magnitud 12 ax1.plot(w, np.abs(h)) 13 ax1.set_title(r'Magnitud $|1 - e^{-j5\omega}|$') 14 ax1.set_ylabel('Amplitud') 15 ax1.set_xticks([-np.pi, -2*np.pi/5, 0, 2*np.pi/5, np.pi]) 16 ax1.set_xticklabels([r'$-\pi$', r'$-2\pi/5$', '0', r'$2\pi/5$', r'$\pi$']) 17 ax1.grid(True) 18 19 # fase 20 ax2.plot(w, np.angle(h)) 21 ax2.set_title(r'Fase $\angle H(e^{j\omega})$') 22 ax2.set_ylabel('Fase [rad]') 23 ax2.set_xlabel('Frecuencia [rad/muestra]') 24 ax2.grid(True) 25 26 plt.tight_layout() 27 plt.show()
