# removing spikes from spectrum

I am working on 50 samples obtained from time domain signal by FFT. It appears at certain frequencies which are -- according to our experimentalist -- due to some issues with their oscilloscope. What is the best way to remove these? They seem to appear at fixed frequencies only but they are not present in all samples to the same degree. • At which frequency do these spikes first occur? Your plots starts at 3 gHz.
– Jdip
Sep 6 at 2:44
• @Jdip changed the picture. Sep 6 at 2:53
• Thank you, but I can't make out where the first spike happens. So, what is the frequency at which the first spike occurs?
– Jdip
Sep 6 at 3:28
• @jdip It is at 250 MHz Sep 6 at 3:29
• Ok, and I'm guessing it's also at 500, 750, 1000, 1250, etc ?
– Jdip
Sep 6 at 3:32

These spikes look like harmonics of some sort of line noise at $$250 \texttt{MHz}$$. To get rid of these, what you need is a comb notch filter.

There are a few ways to build one.

1. If the fundamental (your first spike) is an integer divisor of the sampling frequency (i.e $$f_s/f_0 = \texttt{integer}$$), such a filter can be built using the following transfer function:

$$H(z) = g\frac{1-z^{-n}}{1-az^{-n}}$$ with $$n = \frac{f_s}{f_0}$$

$$g = \frac{1}{1+\beta}$$ $$a = 2g-1$$ $$\beta = \tan\left(\frac{\pi n\texttt{BW}}{f_s}\right)\cdot\frac{\sqrt{1-\alpha^2}}{\alpha}$$ $$\alpha = 10^{-A/20}$$ with $$\texttt{BW}(\texttt{Hz})$$ the width of the notch at $$-A(\texttt{dB})$$. Matlab Code:

    fs = 20e9;
fo = 250e6;
n = fs/fo;
bw = 2e6;
A = 3;
alpha = 10^(-A/20);
beta = tan(pi*n*bw/(2*fs)) * sqrt(1-alpha^2)/alpha;
g = 1/(1+beta);

b = [g zeros(1,n-1) -g]; a = [1 zeros(1,n-1) -(2*g-1)];


2. If $$f_s/f_0 \neq \texttt{integer}$$, or if the spikes aren't actually harmonics, see [this approach]