gpt4 book ai didi

python - 正确地没有在 numpy.fft 中获取频率

转载 作者:太空宇宙 更新时间:2023-11-03 18:08:10 24 4
gpt4 key购买 nike

我在频域中有一个信号。然后我获取了信号的 numpy.fft.ifft。我得到了时域信号。我再次正确地获取了同一时间信号的 fft,我没有得到负频率和正频率(图 3)数字)。 enter image description here

     time       = np.arange(0, 10, .01)
N = len(time)
signal_td = np.cos(2.0*np.pi*2.0*time)
signal_fd = np.fft.fft(signal_td)
signal_fd2 = signal_fd[0:N/2]
inv_td2 = np.fft.ifft(signal_fd2)
fd2 = np.fft.fft(inv_td2)

最佳答案

一般评论:我避免使用 time 作为变量名称,因为 IPython 将其加载为“神奇”命令。

我有时对matplotlib感到困惑的是,当您绘制一个复杂数组时,它实际上绘制的是实部。在代码片段中:

tt       = np.arange(0, 10, .01)
N = len(tt)
signal_td = np.cos(2.0*np.pi*2.0*tt)
signal_fd = np.fft.fft(signal_td)
signal_fd2 = signal_fd[0:N/2]
inv_td2 = np.fft.ifft(signal_fd2)
fd2 = np.fft.fft(inv_td2)

以下数组的 dtypefloat64:ttsignal_td。其他的是complex128。您在 fd2 中只看到一个峰值的原因是它是 exp(4j*np.pi*tt) 的变换,而不是 cos(4*np .pi*tt).

关于python - 正确地没有在 numpy.fft 中获取频率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26468382/

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