gpt4 book ai didi

python - 对称频谱的 iFFT

转载 作者:行者123 更新时间:2023-11-28 17:51:29 32 4
gpt4 key购买 nike

我在对称频谱上执行 iFFT(使用 Python)。为什么结果不是实值信号而是包含复值?

# My symmetric spectrum
spectrum = numpy.array( [1+1j,2+2j,3+3j,3-3j,2-2j] )

# Perform the iFFT
print numpy.fft.ifft(spectrum)

输出:

(2.2+0.2j)
(-1.98979431354+0.2j)
(0.59464641547+0.2j)
(-0.74743281997+0.2j)
(0.942580718037+0.2j)

最佳答案

像这样尝试:

# My symmetric spectrum
spectrum = numpy.array( [0+0j,1+1j,2+2j,3+3j,0+0j,3-3j,2-2j,1-1j] )

# Perform the iFFT
print numpy.fft.ifft(spectrum)

通常 bin 0 是 DC,bin N/2 是奈奎斯特,这两个值都是实数。对于其他项,对称性是围绕奈奎斯特的复共轭。

使用 Octave(MATLAB 克隆),我得到与原始输入数据相同的结果:

octave-3.4.0:1> x = [1+1j,2+2j,3+3j,3-3j,2-2j];
octave-3.4.0:2> y = ifft(x)
y =

2.20000 + 0.20000i -1.98979 + 0.20000i 0.59465 + 0.20000i -0.74743 + 0.20000i 0.94258 + 0.20000i

而根据我上面的输入数据,我得到了一个纯粹真实的结果:

octave-3.4.0:3> x = [0+0j,1+1j,2+2j,3+3j,0+0j,3-3j,2-2j,1-1j];
octave-3.4.0:4> y = ifft(x)
y =

1.50000 -1.56066 0.00000 0.14645 -0.50000 0.56066 -1.00000 0.85355

我假设 numpy 可能使用相同的约定来排序 FFT/IFFT 输入/输出数据。

关于python - 对称频谱的 iFFT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9062387/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com