fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. n = np.arange(0,5)
  5. hdn = (np.sin(np.pi/4) * (n-2)) / (np.pi*(n-2)) # corrected np.pi
  6. wn = 0.5 - 0.5 * np.cos(2 * np.pi*n/4) # corrected np.pi
  7. hn = hdn * wn
  8. hn[2] = 0.25
  9. plt.figure()
  10. plt.subplot(4,1,3)
  11. plt.stem(n,hn)
  12. plt.xlabel('n')
  13. plt.ylabel('h(n)')
  14. plt.title('Hanning window response')
  15. plt.grid(True)
  16. plt.show()
  17.  
Success #stdin #stdout 0.82s 55340KB
stdin
Standard input is empty
stdout
Standard output is empty