基本 FFT 归一化问题
我正在使用 Matlab 对信号进行 FFT,但我陷入了标准化。具体来说,如何将频谱归一化为 dBm 单位。我知道 0.316228 是正确的归一化因子,但我的问题与如何正确归一化垃圾箱有关。
我创建了以下程序来提出我的问题。只需将其剪切并粘贴到 Matlab 中,它就会自行运行。请参阅内嵌问题。
特别是,我很困惑如何标准化垃圾箱。例如,如果 FFT 的索引为 1:end,其中 end 为偶数,那么当我计算 FFT 幅度谱时,索引 2:(end/2) 是否应该乘以 (2/N)?同样,奈奎斯特频率处的 bin(位于索引末尾/2+1)是否归一化为 (1/N)?我知道有很多方法可以根据个人的兴趣进行标准化。假设我使用的信号(St 下面)是从 ADC 捕获的电压。
非常感谢任何反馈。提前致谢!
%% 1. Create an Example Signal
N = 2^21 ; % N = number of points in time-domain signal (St)
St = 1 + rand(N,1,'single'); % St = example broadband signal (e.g. random noise)
% take FFT
Sf = fft(St, N);
Sf_mag = (2/N)*abs(Sf(1: N/2 + 1));
Sf_dBm = 20*log10(Sf_mag / 0.316228); % 0.316338 is peak voltage of 1 mW into 50 Ohms
% Q: Are Sf_mag and Sf_dBm normalized correctly? (assume 0.316338 is correct
% peak voltage to get 1mW in 50 Ohms)
% Q: Should Sf_mag(fftpoints/2 + 1) = (1/N)*abs(Sf(fftpoints/2 + 1) for correct normalization
% of Nyquist frequency? (since Nyquist frequency is not folded in frequency
% like the others are)
%% 2. Plot Result
% create FFT spectrum x-axis
samplerate = 20e9; % 20 Gsamples/sec
fft_xaxis = single(0 : 1 : N/2)';
fft_xaxis = fft_xaxis * single(samplerate/N);
semilogx(fft_xaxis, Sf_dBm, 'b-')
xlabel('Frequency (Hz)');
ylabel('FFT Magnitude (dBm)');
title('Spectrum of Signal (Blue) vs Frequency (Hz)');
xlim([1e4 1e10]);
grid on;
I'm using Matlab to take FFTs of signals, and I'm getting stuck on the normalization. Specifically, how to normalize the spectrum into units of dBm. I know that 0.316228 is the correct normalization factor, but my questions are related to how to normalize the bins correctly.
I created the following program to raise my questions. Just cut and paste it into Matlab and it'll run itself. See questions in-line.
In particular, I'm confused how to normalize the bins. For example, if the FFT has indices 1:end, where end is even, when I calculate the FFT magnitude spectrum, should I multiply by (2/N) for indices 2:(end/2)? Similarly, does the bin at the Nyquist frequency (located at index end/2+1) get normalized to (1/N)? I know there's a bunch of ways to normalize depending on one's interest. Let's say the signal I'm using (St below) are voltages captured from an ADC.
Any feedback is greatly appreciated. Thanks in advance!
%% 1. Create an Example Signal
N = 2^21 ; % N = number of points in time-domain signal (St)
St = 1 + rand(N,1,'single'); % St = example broadband signal (e.g. random noise)
% take FFT
Sf = fft(St, N);
Sf_mag = (2/N)*abs(Sf(1: N/2 + 1));
Sf_dBm = 20*log10(Sf_mag / 0.316228); % 0.316338 is peak voltage of 1 mW into 50 Ohms
% Q: Are Sf_mag and Sf_dBm normalized correctly? (assume 0.316338 is correct
% peak voltage to get 1mW in 50 Ohms)
% Q: Should Sf_mag(fftpoints/2 + 1) = (1/N)*abs(Sf(fftpoints/2 + 1) for correct normalization
% of Nyquist frequency? (since Nyquist frequency is not folded in frequency
% like the others are)
%% 2. Plot Result
% create FFT spectrum x-axis
samplerate = 20e9; % 20 Gsamples/sec
fft_xaxis = single(0 : 1 : N/2)';
fft_xaxis = fft_xaxis * single(samplerate/N);
semilogx(fft_xaxis, Sf_dBm, 'b-')
xlabel('Frequency (Hz)');
ylabel('FFT Magnitude (dBm)');
title('Spectrum of Signal (Blue) vs Frequency (Hz)');
xlim([1e4 1e10]);
grid on;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不完全清楚你想要完成什么,但这里有一些提示可以让你调试自己的程序。
执行
fft([1 1 1 1])
。执行 fft([1 1 1 1 1 1 1 1]) 。特别是观察输出幅度。是你所期望的吗?然后执行
fft([1 -1 1 -1])
。执行 fft([1 -1 1 -1 1 -1 1 -1]) 。对不同的信号长度和频率重复此操作。这应该允许您相应地规范化您的信号。另外,对
ifft
而不是fft
执行相同的操作。这些对于各种 FFT 实现来说都是很好的健全性检查,因为虽然大多数实现可能会将1/N
放在逆变换前面,但其他实现可能会将1/sqrt(N)
在正变换和逆变换之前。I am not totally clear about what you are trying to accomplish, but here are some tips that will let you debug your own program.
Do
fft([1 1 1 1])
. Dofft([1 1 1 1 1 1 1 1])
. In particular, observe the output magnitude. Is it what you expect?Then do
fft([1 -1 1 -1])
. Dofft([1 -1 1 -1 1 -1 1 -1])
. Repeat for various signal lengths and frequencies. That should allow you to normalize your signals accordingly.Also, do the same thing for
ifft
instead offft
. These are good sanity checks for various FFT implementations, because while most implementations may put the1/N
in front of the inverse transform, others may put1/sqrt(N)
in front of both forward and inverse transforms.请参阅此答案:
FFT 归一化
一些软件包和参考资料对傅里叶系数的归一化很草率。
假设是真实信号,则归一化步骤为:
1) 频域中的功率必须等于时域中的功率。
2) 除 DC 项和奈奎斯特项外,傅里叶系数的幅度是重复的 (x2)。 DC 和奈奎斯特项仅出现一次。根据数组索引的启动/停止方式,您需要小心。简单地加倍功率以获得单侧频谱是错误的。
3) 要获得功率密度 (dBm/Hz),您需要标准化为各个频率仓大小。
See this for an answer:
FFT normalization
Some software packages and references get sloppy on the normalization of the Fourier coefficients.
Assuming a real signal, then the normalization steps are:
1) The power in the frequency domain must equal the power in the time domain.
2) The magnitude of the Fourier coefficients are duplicated (x2) except for DC term and Nyquist term. DC and Nyquist terms appear only once. Depending on how your array indexing starts/stop, you need to be careful. Simply doubling the power to get a one sided spectrum is wrong.
3) To get power density (dBm/Hz) you need to normalize to the individual frequency bin size.