Julia DSP期刊N> NFFT是错误,为什么?
这
n = length(s)
# n = 25920169
nfft = 8192
noverlap = Int64(floor(nfft/2))
window = hanning(nfft)
#sp = spectrogram(s, n, noverlap; nfft=nfft, fs=1, window=window)
sp = periodogram(s; nfft=nfft, fs=1, window=window)
引发了错误
nfft must be >= n
,但文档说:
If length(s) < nfft, then the input is padded with zeros.
这是否意味着NFFT&lt; n应该正确吗?
This
n = length(s)
# n = 25920169
nfft = 8192
noverlap = Int64(floor(nfft/2))
window = hanning(nfft)
#sp = spectrogram(s, n, noverlap; nfft=nfft, fs=1, window=window)
sp = periodogram(s; nfft=nfft, fs=1, window=window)
throws the error
nfft must be >= n
But the documentation says:
If length(s) < nfft, then the input is padded with zeros.
Doesn't it mean that nfft < n should be correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为FFT长度
nfft
应该大于信号长度n
以防止混叠。期刊
函数在内部使用FFT,其中长度表示为nfft
。从理论上讲,使用FFT时,时间域和频域中的信号都是离散和周期性的,其中该周期由nfft
给出。因此,如果指定小于信号长度n
的nfft
,这实际上会在时间域中引入混叠,以使信号周期性使用nfft 。
例如,如果您有一个序列
1 2 3 4 5
,则假设您的周期也是5
,则具有原始序列。 看起来就像
现在,假设您有一个
3
的时期,那么当您使用n&gt进行此序列时, nfft
,您正在使用此别名序列。您可以手动允许
n&gt; nfft
通过应用包装(x,nfft)
作为bellow并将其输出输出到ofermogram ,MATLAB可以做到这一点。
例如:
I think that the FFT length
nfft
should be greater than the signal lengthn
to prevent aliasing.The
periodogram
function uses FFT internally, where the length is denoted asnfft
. In theory, when using FFT, the signal in both time domain and frequency domain are discrete and periodic, where the period is given bynfft
. So, if you specify annfft
that is less than the signal lengthn
, this actually introduces aliasing in the time domain to make the signal periodic withnfft
.For example, if you have a sequence
1 2 3 4 5
, assuming that your period is also5
, you havei.e., the original sequence. Now assume you have a period of
3
, then it looks likeWhen you take FFT of this sequence with
n > nfft
, you are working with this aliased sequence.You can manually allow for
n > nfft
by applying thewrap(x,nfft)
as bellow and feeding its output toperiodogram
, MATLAB does exactly that.For example: