# low pass filter in fft

I have signal. I do Fast Fourier transform on it and now I have this output. I want to delete the other except two that have high altitude. Can you help me ?

My f sample is 2500.

My complete time is 10s.

My time rate is 0.0004s.

I need to see the code behind your graph because the numbers you put down are not making sense with that figure. Your graph should cover X values from 1-12501 if it's just FFT indices or 0-1250 for actual frequencies.

If you're looking to filter the two frequencies with the greatest magnitude no matter what the input signal is, you can find their frequencies by searching for local maxima. If you have the Signal Processing Toolbox, you can use this code to find the peaks and their indices, and then convert those indices into an actual radial frequency.

[pks,locs] = findpeaks(mag_fft_out);   % this fft should be 0-fs/2 ONLY
[throw_away,I1] = max(pks);            % find biggest peak and return index in peak vector
n1 = locs(I1);                         % find location of peak index in FFT vector
omega1 = 2.*pi.*n1./N;                 % N is the length of your original sequence in samples (T./fs)
pks(I1) = [];                          % remove primary peak from peak vector
locs(I1) = [];                         % remove primary peak from peak location vector
[throw_away,I2] = max(pks);            % find (remaining/second) biggest peak and return index
n2 = locs(I2);                         % find location of peak index in FFT vector
omega2 = 2.*pi.*n2./N;


This will also work for finding the peaks once or you could figure it out manually (Mk I Eyeball + Math)

After that you need to design a filter for each peak frequency. I highly recommend you use the MATLAB 1-D Digital Filter function filter(b,a,x) and choose your coefficients based on what characteristics you need. In all likelihood, a simple 2nd order bandpass will work for both. Look up how to design a digital filter. The article on Wikipedia is a great start and even has diagrams showing how the coefficients work.

I'm not sure this is what you're asking for. You say "delete" but it's not quite that simple. I supposed you could set all other values to zero except the peaks, and then if you want it back as a signal you inverse FFT it, but I've never actually tried that.