Transformada de Fourier de la función Sinc.

  1. import numpy as np
  2. import pylab as plt
  3. from scipy.fftpack import fft
  4.  
  5. N = 500 # number of sample points
  6. dt = 1. / 1000 # sample spacing
  7.  
  8. npp=3
  9. nN=N*npp
  10. t = np.linspace(-N*dt, N*dt, nN)
  11.  
  12. y=np.sinc(200*t)
  13. #y=np.abs(np.sinc(t))
  14. plt.figure(1)
  15. plt.plot(t,y)
  16. plt.grid(True), plt.xlabel('Tiempo')
  17. plt.title(u'Sinc(200t)')
  18. plt.xlim([-6./200,6./200])
  19.  
  20. # FFT
  21. yf = fft(y)
  22. tf = npp*np.linspace(-1./(4.*dt), 1./(4.*dt), nN)
  23. spectrum = 1./nN * np.concatenate([np.abs(yf[nN/2:nN]), np.abs(yf[0:nN/2])])
  24.  
  25. #figure1 = plt.figure(4, (10, 5))
  26. plt.figure(2)
  27. plt.plot(tf, spectrum, '-')
  28. plt.grid()
  29. plt.xlim([-300,300])
  30. plt.title(u'Espectro de magnitud |X(j$\omega$)|')
  31. plt.xlabel('Frecuencia [Hz]')
  32. plt.ylabel('Magnitud |X(j$\omega$)|')

No hay comentarios.:

Publicar un comentario

Related Posts Plugin for WordPress, Blogger...