# Looking for a simple and effective notch filter

I ran a finite-difference simulation and the behavior of an output signal, $s$, in time, $t$ (sampled with period $\Delta t$) behaves approximately as in the figure below. It is well-described by a slowly-varying pulse plus a rapidly oscillating signal of the same envelope with lower amplitude.

For concreteness, I computed this sample signal in MATLAB with the following code.

f_noise = 20;
t = linspace(-4,4,2e3);
signal = exp(-t.^2);
noise = 0.25*exp(-t.^2).*sin(2*pi*f_noise*t);
signal_w_noise = signal + noise;


I emphasize that this is just a sample signal and not the actual data I want to analyze.

I wish to compute the "time-average" of the signal. By this I mean the signal without the rapidly oscillating component (which we could call noise). To get a clear picture of the problem, I calculated the Fourier transform of the signal approximately using MATLAB's fft function and obtained the spectra below.

From this plot, I suspect a notch-filter could do the trick. However, I know very little of signal processing and I know how to use first-order filters from undergraduate electric-circuit courses. What is a simple to use but effective notch-filter I could use? I am particularly looking for the transfer function in the frequency domain of such notch-filter, because the software I use to generate the data is equipped with a FFT algorithm, so I'd like to do the processing there and avoid exporting the whole data to, say, MATLAB.

• you can get a simple and effective second-order IIR notch filter from this. sorry i haven't done a pdf copy with decent math markup. i dunno why i haven't. – robert bristow-johnson Oct 19 '17 at 3:28
• Using a notch filter means that you know the frequency of your noise. If that is the case, why don't you give us a little more detail about your application, maybe it could help propose a better solution than the notch filter. – Pier-Yves Lessard Nov 19 '17 at 3:21
• Could you share the signal samples? – Royi May 18 '18 at 5:09