JuliaMelkozerova

БПФ

Mar 25th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. from numpy import array, float64, complex64
  2. from numpy.fft import fft as fft_numpy, ifft as ifft_numpy
  3. from matplotlib import pylab as plt
  4.  
  5. #Изначальный массив отсчетов
  6. arr_in = array([140, 32, 1, 50], dtype = complex64)
  7.  
  8. #Прямое БПФ
  9. forward_fft_numpy_res = fft_numpy(arr_in)
  10.  
  11. #Обратное преобразование Фурье
  12. backward_fft_numpy_res = ifft_numpy(forward_fft_numpy_res)
  13.  
  14. #Вывод данных и графиков
  15. print (arr_in)
  16. print (forward_fft_numpy_res)
  17. print (backward_fft_numpy_res)
  18.  
  19. plt.xlabel('j')
  20. plt.ylabel('u')
  21. plt.bar ([0,1,2,3], arr_in,width = 0.02)
  22. plt.show()
  23.  
  24. plt.xlabel('k')
  25. plt.ylabel('U')
  26. plt.bar ([0,1,2,3], forward_fft_numpy_res,width = 0.02,color = 'red')
  27. plt.show()
  28.  
  29. plt.xlabel('j')
  30. plt.ylabel('u back')
  31. plt.bar ([0,1,2,3], backward_fft_numpy_res,width = 0.02)
  32. plt.show()
Add Comment
Please, Sign In to add comment