I perform FFT-IFFT in order to take out 50 Hz and its harmonics from my signal, using Matlab. For this purpose I break down my signal into windows of 1024 samples, and perform FFT on it. I do overlapping of 50% as well. After FFT is done, I take out those harmonics, and do IFFT in order to get filtered data. My question is: How to sum up all those windows with overlaps to get a signal?
my code is below. As you can see, I perform FFT-IFFT on each window and do not know how to get all windows back together.
[y, Fs, nbits] = wavread([fileName]); %read the data
[noSamples, noChannels] = size(y);
N = 1024; %window length 2^10
winLength=N;
Fres = Fs/N; % resolution frequency
nofWins = floor(noSamples/winLength); % No of full windows
noWins = round((100/50)*nofWins - 1); % rounded no of windows
yPaddedLength = floor(noWins*0.5*winLength + winLength); % padding wth 0
yZeroPadded =[y zeros(1, (yPaddedLength - noSamples))]; % padded signal y
nofWinsPadded = round(yPaddedLength/winLength);
noWinsPadded = round((100/50)*nofWinsPadded - 1); % no of padded windows
odd = true;
for k = 1:(noWinsPadded-1)
j = floor(0.5*k);
at = j*winLength + 1;
overlapWinLength=floor(0.5*winLength);
range = at:(at + winLength - 1);
if odd
data = yZeroPadded(range, 1);
data_sum=sum(data); % from now on - to perform
% DC removal
data_average=data_sum/N;
data=data-data_average;
else
data = yZeroPadded(range+overlapWinLength, 1);
data_sum=sum(data);
data_average=data_sum/N;
data=data-data_average;
end;
odd=~odd;
spectrum = fft(data);
F=length(spectrum);
F=spectrum;
F(10:11)=zeros; % FFT No equals to zero removes harmonics
F(17:18)=zeros % and so on
filtered_signal=IFFT(F);
Thanking you in anticipation, Elen Che