Skip to content
Related Articles

Related Articles

Improve Article
scipy.fftshift() in Python
  • Last Updated : 29 Aug, 2020

With the help of scipy.fftshift() method, we can shift the lower and upper half of vector by using fast fourier transformation and return the shifted vector by using this method.

Syntax : scipy.fft.fftshift(x)

Return : Return the transformed vector.

Example #1 :

In this example we can see that by using scipy.fftshift() method, we are able to shift the lower half and upper half of the vector by using fast fourier transformation and return the shifted vector.



Python3




# import scipy and numpy
import scipy
import numpy as np
  
x = np.arange(6)
# Using scipy.fftfreq() method
gfg = scipy.fft.fftshift(x)
  
print(gfg)

Output :

[3 4 5 0 1 2]

Example #2 :

Python3




# import scipy and numpy
import scipy
import numpy as np
  
x = np.arange(11)
# Using scipy.fftfreq() method
gfg = scipy.fft.fftshift(x)
  
print(gfg)

Output :

[ 6  7  8  9 10  0  1  2  3  4  5]

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :