Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. N = 1024
  2. freq = 8000
  3.  
  4.  
  5. f1 = 500
  6. f2 = 1200
  7. n = np.arange(N)
  8. w = np.random.normal(0,1,N)
  9. s = 0.5*np.sin(2*np.pi*n*f1/freq) + np.sin(2*np.pi*n*f2/freq)
  10. y = s + 0.1*w
  11. pw = signal.hann(N) * w
  12. ps = signal.hann(N) * s
  13. py = signal.hann(N) * y
  14.  
  15. plt.figure(figsize = (20,15))
  16.  
  17. plt.subplot(3,2,1)
  18. plt.title("Periodogram Power Spectral Density Estimate")
  19. plt.xlabel("Normalized Frequency")
  20. plt.xlim(0,1)
  21. plt.psd(w, N)
  22.  
  23. plt.subplot(3,2,3)
  24. plt.title("Periodogram Power Spectral Density Estimate")
  25. plt.xlabel("Normalized Frequency")
  26. plt.xlim(0,1)
  27. plt.psd(s, N)
  28.  
  29. plt.subplot(3,2,5)
  30. plt.title("Periodogram Power Spectral Density Estimate")
  31. plt.xlabel("Normalized Frequency")
  32. plt.xlim(0,1)
  33. plt.psd(y, N)
  34.  
  35. plt.subplot(3,2,2)
  36. plt.title("Periodogram Power Spectral Density Estimate")
  37. plt.xlabel("Normalized Frequency")
  38. plt.xlim(0,1)
  39. plt.psd(pw, N)
  40.  
  41. plt.subplot(3,2,4)
  42. plt.title("Periodogram Power Spectral Density Estimate")
  43. plt.xlabel("Normalized Frequency")
  44. plt.xlim(0,1)
  45. plt.psd(ps, N)
  46.  
  47. plt.subplot(3,2,6)
  48. plt.title("Periodogram Power Spectral Density Estimate")
  49. plt.xlabel("Normalized Frequency")
  50. plt.xlim(0,1)
  51. plt.psd(py, N)
  52. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement