当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Numpy np.fft()用法及代码示例


借助np.fft()方法,我们可以获得一维傅立叶变换np.fft()方法。

用法: np.fft(Array)
返回:Return a series of fourier transformation.

范例1:
在这个例子中,我们可以通过使用np.fft()方法,我们可以使用该方法获得一系列的傅立叶变换。


# import numpy 
import numpy as np 
  
a = np.array([5, 4, 6, 3, 7]) 
# using np.fft() method 
gfg = np.fft.fft(a) 
  
print(gfg)

输出:

[25. + 0.j 1.11803399 + 1.08981379j -1.11803399 + 4.61652531j
-1.11803399 - 4.61652531j 1.11803399 - 1.08981379j]

范例2:

# import numpy 
import numpy as np 
  
a = np.array([-5.5, 4.4, -6.6, 3.3, -7.7]) 
# using np.fft() method 
gfg = np.fft.fft(a) 
  
print(gfg)

输出:

[-12.1 + 0.j -3.85 - 5.68870985j -3.85 - 16.52766106j
-3.85 + 16.52766106j -3.85 + 5.68870985j]



相关用法


注:本文由纯净天空筛选整理自Jitender_1998大神的英文原创作品 Python | Numpy np.fft() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。