當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python scipy.fftshift()用法及代碼示例

借助於scipy.fftshift()方法,我們可以使用快速傅立葉變換對向量的上半部分和下半部分進行移位,並使用此方法返回移位後的向量。

用法:scipy.fft.fftshift(x)

Return:返回轉換後的向量。

範例1:

在此示例中,我們可以看到,通過使用scipy.fftshift()方法,我們可以使用快速傅立葉變換對向量的下半部分和上半部分進行移位,然後返回移位後的向量。



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)

輸出:

[3 4 5 0 1 2]

範例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)

輸出:

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

相關用法


注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 scipy.fftshift() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。