用正弦/余弦表示的傅里叶级数的fft输出

2024-05-13 01:47:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否有人能帮助我更好地理解fourier级数,看看实际用作sine和{}函数序列中的coefficients。在

我有一些函数,我采样4次得到[0, 1, 0, 1], therefore N == 4。我怎么把它表示成傅立叶级数呢?使用numpy,fft给了我…[ 2.+0.j, 0.+0.j, -2.+0.j, 0.+0.j]基本上,我需要看到这个扩展,而不是求和法,因为否则我只会有一个由恐惧引起的多云思维。我指的是sin(something * x) + cos(something * x) +。。。在


Tags: 函数fftnumpy序列sincossomething思维
2条回答

离散傅里叶变换(DFT)与傅里叶级数can be summarized as follows之间的关系

The Fourier series coefficients of a periodic signal x are given by the DFT of one period of x, divided by N, were N is also the number of samples in each period.

这意味着只有当信号的周期等于其采样率的N倍时,傅里叶级数和DFT才是相关的,一般情况下并非如此。在

因此,在实际中,当你需要DFT时,使用scipy.fftpack.fft,而Fourier级数系数可以用a direct summation in python计算。网上有很多关于这两个概念的文献,但不要把两者混为一谈,因为这可能会让人大惑不解,反而会有所帮助。在

我猜你在找这样的东西:

from numpy.fft import fft
x = array([ 0.,  1.,  0.,  1.])
y = fft(x)

#first rescale it
nfft = len(x)
y /= nfft

n = arange(0,4)
# notice that y[1] and y[3] are identically zero:
x_reconstructed = y[0] +y[2] * cos(2*2*pi/nfft*n)

现在你有了x_reconstructed==x。现在您可以转到DFT页面,特别是this方程,并根据上面的例子理解求和符号。在

相关问题 更多 >