Magnitude of output signal after fourier transform filter?

4 views (last 30 days)
Hi,
I have a spectrum which has a lot of high frequency noise that I want to eliminate. I have used the f = fft(data) function to take the fourier transform of the data, and then replaced all the values above the frequency I want to keep to zeros. I have then used the f2 = ifft(f) function to convert back to the spectum I want, and use plot(lamda,real(f2)). However, the peaks I want have lost magnitude? Does anyone know how to sort this?
Thanks!

Answers (3)

Honglei Chen
Honglei Chen on 2 Nov 2012
If you want magnitude, it should be
abs(f2)

Wayne King
Wayne King on 2 Nov 2012
Edited: Wayne King on 2 Nov 2012
Can you give us an example? What do you mean by "the peaks I want have lost magnitude?" Presumably you are talking about a time-domain signal here, are you saying the amplitude of the component you want to keep has lost amplitude?
Remember you need to remove the positive and negative frequency components for a real-valued input signal and you should not have to do real() after the inverse Fourier transform
Fs = 1000;
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+sin(2*pi*200*t)+cos(2*pi*250*t);
xdft = fft(x);
% set components higher and lower than 100 Hz to zero
idx = 101; % index for 100 Hz
posidx = idx-2:idx+2;
conjidx = length(x)-idx+2; % conjugate index
negidx = conjidx-2:conjidx+2;
Idx = [posidx negidx];
ydft = zeros(size(xdft));
ydft(Idx) = xdft(Idx);
xrec = ifft(ydft,'symmetric');
plot(t,xrec)
I would recommend using a proper lowpass filter by the way.

Image Analyst
Image Analyst on 2 Nov 2012
What peaks are you talking about? Peaks in "data" or peaks in "f" or "f2"? Any peaks you had originally in "data" will of course be reduced in "f2" because you filtered out high frequencies. Any peaks in the spectrum, what you called f, may have been erased when you zeroed them out. Please explain clearly what you mean by peaks - where they are and why you think they should not be reduced.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!