I have a signal in Matlab defined by signal and t. As it is a noisy signal, I want to delete every component below a certain given frequency "x" Hz with the FFT. How could I do it? I guess the procedure is FFT the signal, delete those components and then apply the IFFT, but I don't know how to implement it. Any help is appreciated!


1 Answer 1


In fact, deleting a certain frequency range from the FFT equals settings these frequency components to zero. Hence, you end up with the following code:

N = 1000;
signal = randn(N, 1);

N_clear = 490;

% Remove the calls to fftshift, if you want to delete the lower frequency components
S = fftshift(fft(signal));   
S_cleared = S;
S_cleared(1:N_clear) = 0;
S_cleared(end-N_clear+2:end) = 0;
S_cleared = fftshift(S_cleared);

signal_cleared = ifft(S_cleared);

title('input signal');

title('input spectrum');

title('output spectrum');

title('output signal');

As you can see, the input signal is very quickly varying. Then, after filtering out almost all higher frequency parts, you end up with a smooth signal.

Note, that normally you use FIR/IIR lowpass/highpass filters for realtime-signal processing, because the FFT is block-based and cannot produce nice transitions between the processed blocks.

Resulting IO-relation

  • $\begingroup$ That's perfect, but what do you mean with N_clear? If I want to delete frequency components below 1Hz, knowing that f=k*fs/N, with a given sampling frequency, N the length of the signal and k a vector of the length of the signal, I should delete every component k that is under 1Hz from the S vector? Thanks for the answer! @maximilian-matthé $\endgroup$
    – euskadi
    Nov 9, 2016 at 15:27
  • $\begingroup$ N_clear is the amount of frequency bins you want to erase. Sure, you can relate this to the actual physical frequencies with the formula you provided. $\endgroup$ Nov 9, 2016 at 17:08
  • $\begingroup$ @MaximilianMatthé, I want to filter out all the frequencies above 80 Hz from my signal. In this case what is N_clear? How should I modify the code to filter out all the higher frequencies? Thank you. $\endgroup$
    – aneps
    Sep 27, 2018 at 22:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.