0

我在 n=1..4 的情况下使用 python 在区间 -5 .. +5 的 400 个点处绘制了一个余弦采样:

import matplotlib.pyplot as plt
import numpy

for n in range(1,5):
    x = numpy.linspace(-5,5,num=400)
    series = numpy.cos(1e4/n*x)
    plt.figure()
    plt.plot(series)

但是对于 n = 3,该图看起来不像余弦,我认为这是由于采样误差。如何获得具有不同频率(即不同 n)的恒定样本的平滑余弦图?

4

1 回答 1

0

将您的计算更改为series = numpy.cos(2*numpy.pi/n*x).

乘以1e4意味着您的余弦每个周期少于 2 个点,从而导致aliasing

于 2013-04-11T10:32:57.550 回答