qslazio
Full Member level 3
Folks,
Since windowed FFT of a signal with DC offset will produce the shape of the FFT of the window function around DC bins, which may mask out the interested signals at those bins, I'd like to remove DC component "during" FFT analysis.
My question is whether to remove the DC offset of the signal "before" or "after" the windowing. My understanding is to remove the DC before windowing otherwise aliasing due to windowing of the DC offset will still be there although DC bin is cleared indeed.
However, I have 2 example signals (i.e. as linked below) indicates inconsistent choices.
For "signal1.csv", it seems to be better to remove DC after windowing. For "signal2.csv", it seems to be better to remove DC before windowing.
The most interesting thing is that for "signal1.csv", the DC bin level of FFT with removing DC before windowing is much bigger than the FFT with DC offset!!
Anyone can explain how to do this correctly? Thanks!!!
FFT Plots:
signal1.jpg: https://docs.google.com/open?id=0B48Rh8E6owAkNjBvQkNXaXN1S3c
signal2.jpg: https://docs.google.com/open?id=0B48Rh8E6owAkc3Z3dVVqLUQ5OVE
Raw Data:
signal1.csv: https://docs.google.com/open?id=0B48Rh8E6owAkVXZkUENFV2ZJTEU
signal2.csv: https://docs.google.com/open?id=0B48Rh8E6owAkeGNtcWNOaGluZ0E
Matlab code:
test.m: https://docs.google.com/open?id=0B48Rh8E6owAkenNBOFV3ZUVmWEk
Code in "test.m" is posted here
clear
% better to remove DC after windowing
data = load('signal1.csv');
% better to remove DC before windowing
%data = load('signal2.csv');
signal = data(1:8192,2);
win = hanning(8192,'periodic');
wsignal = signal.*win;
% FFT with DC component
wfft = fft(wsignal)/8192;
% FFT without DC component after windowing
wfft_nowdc = fft(wsignal-mean(wsignal))/8192;
% FFT without DC component before windowing
wfft_nodc = fft((signal-mean(signal)).*win)/8192;
figure(1);
hold on;
plot(20*log10(abs(wfft)), 'b+', 'LineWidth',2);
plot(20*log10(abs(wfft_nowdc)), 'r', 'LineWidth',2);
plot(20*log10(abs(wfft_nodc)), 'g', 'LineWidth',2);
legend('original','remove DC after windowing','remove DC before windowing');
grid on;
Since windowed FFT of a signal with DC offset will produce the shape of the FFT of the window function around DC bins, which may mask out the interested signals at those bins, I'd like to remove DC component "during" FFT analysis.
My question is whether to remove the DC offset of the signal "before" or "after" the windowing. My understanding is to remove the DC before windowing otherwise aliasing due to windowing of the DC offset will still be there although DC bin is cleared indeed.
However, I have 2 example signals (i.e. as linked below) indicates inconsistent choices.
For "signal1.csv", it seems to be better to remove DC after windowing. For "signal2.csv", it seems to be better to remove DC before windowing.
The most interesting thing is that for "signal1.csv", the DC bin level of FFT with removing DC before windowing is much bigger than the FFT with DC offset!!
Anyone can explain how to do this correctly? Thanks!!!
FFT Plots:
signal1.jpg: https://docs.google.com/open?id=0B48Rh8E6owAkNjBvQkNXaXN1S3c
signal2.jpg: https://docs.google.com/open?id=0B48Rh8E6owAkc3Z3dVVqLUQ5OVE
Raw Data:
signal1.csv: https://docs.google.com/open?id=0B48Rh8E6owAkVXZkUENFV2ZJTEU
signal2.csv: https://docs.google.com/open?id=0B48Rh8E6owAkeGNtcWNOaGluZ0E
Matlab code:
test.m: https://docs.google.com/open?id=0B48Rh8E6owAkenNBOFV3ZUVmWEk
Code in "test.m" is posted here
clear
% better to remove DC after windowing
data = load('signal1.csv');
% better to remove DC before windowing
%data = load('signal2.csv');
signal = data(1:8192,2);
win = hanning(8192,'periodic');
wsignal = signal.*win;
% FFT with DC component
wfft = fft(wsignal)/8192;
% FFT without DC component after windowing
wfft_nowdc = fft(wsignal-mean(wsignal))/8192;
% FFT without DC component before windowing
wfft_nodc = fft((signal-mean(signal)).*win)/8192;
figure(1);
hold on;
plot(20*log10(abs(wfft)), 'b+', 'LineWidth',2);
plot(20*log10(abs(wfft_nowdc)), 'r', 'LineWidth',2);
plot(20*log10(abs(wfft_nodc)), 'g', 'LineWidth',2);
legend('original','remove DC after windowing','remove DC before windowing');
grid on;
Last edited: