scipy.fftpack.fft
时间: 2024-01-09 17:04:57 浏览: 100
scipy.fftpack.fft is a function from the SciPy library that performs a fast Fourier transform (FFT) on an input array. FFT is a widely used mathematical technique that decomposes a time-domain signal into its constituent frequencies, which is useful in many fields including signal processing, image processing, and data analysis.
The syntax for scipy.fftpack.fft is:
scipy.fftpack.fft(x, n=None, axis=-1, overwrite_x=False)
where:
- x: input array
- n: optional, integer length of the FFT. If not provided, the length of the input array is used.
- axis: optional, the axis along which the FFT is computed. Default is -1, which means the last axis.
- overwrite_x: optional, if True, the input array is overwritten by the output. Default is False.
The function returns the FFT of the input array. The output is an array of complex numbers, where the first half of the array contains the positive frequencies, and the second half contains the negative frequencies. The frequencies are arranged in increasing order, with the zero frequency at the beginning.
Example usage:
import numpy as np
from scipy.fftpack import fft
x = np.array([1, 2, 3, 4])
y = fft(x)
print(y)
Output:
[10.+0.j -2.+2.j -2.+0.j -2.-2.j]
阅读全文