点数如何改变MATLAB中的FFT [英] How does number of points change a FFT in MATLAB

查看:164
本文介绍了点数如何改变MATLAB中的FFT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取信号的fft(signal, nfft)时,nfft如何改变结果,为什么?我可以为nfft设置一个固定值,例如2^18,还是需要转到2^nextpow2(2*length(signal)-1)?

我正在通过自相关的FFT计算两个信号的功率谱密度(PSD),我想比较结果.由于信号的长度不同,因此我担心如果不修复nfft,将使比较变得非常困难!

解决方案

大多数现代FFT实现(包括基于FFTW的MATLAB)现在很少需要将信号的时间序列填充到等于2的幂的长度.但是,几乎所有的实现都将为数据向量的FFT的2倍幂提供更好,有时更好的性能.特别是对于MATLAB而言,填充到2的幂或具有很多低质数的长度的填充将为您提供最佳性能(N = 1000 = 2 ^ 3 * 5 ^ 3将是极好的,N = 997将是一个糟糕的选择)

零填充不会增加PSD中的频率分辨率,但是会减小频域中的bin大小.因此,如果将NZeros添加到长度为N的信号向量,FFT现在将输出长度为(N + NZeros)/2 + 1的向量.这意味着每个频率仓现在将具有以下宽度:

bin宽度(Hz)= F_s/(N + NZeros)

其中F_s是信号采样频率.

如果发现需要在频域中分离或识别两个紧密的空间峰,则需要增加样本的时间.您会很快发现零填充功能并没有为您带来任何好处-直观地讲,这就是我们所期望的.我们如何才能期望在功率谱中获得更多信息,而又不向输入中添加更多信息(更长的时间序列)呢?

最好

保罗

When taking fft(signal, nfft) of a signal, how does nfft change the outcome and why? Can I have a fixed value for nfft, say 2^18, or do I need to go 2^nextpow2(2*length(signal)-1)?

I am computing the power spectral density(PSD) of two signals by taking the FFT of the autocorrelation, and I want to compare the the results. Since the signals are of different lengths, I am worried if I don't fix nfft, it would make the comparison really hard!

解决方案

Most modern FFT implementations (including MATLAB's which is based on FFTW) now rarely require padding a signal's time series to a length equal to a power of two. However, nearly all implementations will offer better, and sometimes much much better, performance for FFT's of data vectors w/ a power of 2 length. For MATLAB specifically, padding to a power of 2 or to a length with many low prime factors will give you the best performance (N = 1000 = 2^3 * 5^3 would be excellent, N = 997 would be a terrible choice).

Zero-padding will not increase frequency resolution in your PSD, however it does reduce the bin-size in the frequency domain. So if you add NZeros to a signal vector of length N the FFT will now output a vector of length ( N + NZeros )/2 + 1. This means that each bin of frequencies will now have a width of:

Bin width (Hz) = F_s / ( N + NZeros )

Where F_s is the signal sample frequency.

If you find that you need to separate or identify two closely space peaks in the frequency domain, you need to increase your sample time. You'll quickly discover that zero-padding buys you nothing to that end - and intuitively that's what we'd expect. How can we expect more information in our power spectrum w/o adding more information (longer time series) in our input?

Best,

Paul

这篇关于点数如何改变MATLAB中的FFT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆