Good evening to everyone, my question is probably trivial, but I'm new to DSP. I have a tone at the frequency 0.5 Hz, amplitude 0.001 V, and with a big DC component of 0.5 V. This signal is sampled at 900 Hz (I know that it is much higher than necessary). I generate the samples as follows:

fsin = 0.5; fs = 900; Ts = 1 / fs;
t = 0:Ts:100;
sig = 500e-3 + 1e-3 * sin(2 * pi * fsin * t);

After I compute the spectrum as follows:

NFFT = 2 ^ nextpow2(numel(sig));
Spectrum = fftshift(fft(sig, NFFT));

Plotting this spectrum near the tone, I see that it is completely drowned by the sidelobes of the DC component:

enter image description here

I would expect that even if I try to filter the signal with a pass-band of 0.2-0.8 Hz (thus containing the tone) I will not be able to see the tone anyway, because the big sidelobes dominate the tone in 0.2-0.8 Hz. Instead, surprisingly, adopting the following filter

[sf,~] = bandpass(sig, [0.2,0.8], fs);

the resulting spectrum shows a clear tone:

enter image description here

Therefore, my question is: how is it possible that the filter is able to recover the tone even if it is completely drowned by the DC component's sidelobes in the pass-band? Thank to all.

  • $\begingroup$ Either extend the length from 100 to some bigger number and/or apply a window function to your signal. Pretty sure those are your only options for bringing out the sinusoidal signal. $\endgroup$
    – Dan Szabo
    Commented Feb 2, 2021 at 17:37
  • $\begingroup$ I'm not quite sure what your computation of NFFT is, but if you're doing a 128-point FFT on 100 points of mostly-1/2, then what you're actually doing an FFT on is a 28-point rectangular negative-going pulse. Any modern FFT package will do a 100-point FFT just fine -- have you tried that? $\endgroup$
    – TimWescott
    Commented Feb 2, 2021 at 18:26
  • $\begingroup$ Are you plotting the magnitudes or just the real data from the FFT? $\endgroup$
    – Dan Szabo
    Commented Feb 2, 2021 at 22:43

1 Answer 1


The reason the bandpass filter eliminated the problem is because it removed the DC component. This can also be done by simply subtracting the average before taking the DFT. However there is much more to understand in this question that should be of interest to the OP, and after reading and understanding the detail given below, this first statement should make complete sense.

To be clearer, I would not refer to the effect the OP is seeing as the "sidelobes of a DC signal" but more specifically the sidelobes of the rectangular window that was used to select that portion of the DC signal in time, prior to computing the DFT. As I will explain in detail, the primary consideration is to first choose the sampling rate to be much lower such that the time duration can be increased with no penalty (for the cases when time can be arbitrarily extended such as this). A secondary consideration is improved windowing, if needed. I will detail both below.

For the benefit of the OP who is new to DSP, I will attempt to answer this as simply as possible with the basics of what is occurring. Starting with consideration of the "DC" component alone: To be truly "DC" the signal must extent to positive and negative infinity in time, as "DC" implies a constant level that never changes. The Fourier Transform of such an unrealizable signal would be the expected impulse in frequency at $F=0$, with no energy at any other frequency locations (no sidelobes). The realizable signal is both causal (starts at $t=0$) and time limited (the OP used 100 seconds). The asymmetry in time leads to a phase shift in frequency but has no other change to the magnitude of the resulting Spectrum. I will focus on the magnitude result so phase effects and causality will not be mentioned further other than that main point.

So to recap, IF the signal at DC extended to positive and minus infinity, the Fourier Transform would be an impulse in Frequency at $F=0$. However what we do in the DFT computation (in addition to sampling effects that I won't cover) is select a time limited sample of the waveform which is equivalent to multiplying the waveform in time with a "rectangular window", a function that is unity over the time interval of choice.

Multiplying two waveforms in time is equivalent to convolving those two waveforms in frequency (and vice versa). Therefore the effect of taking only a portion of the DC waveform in time with a rectangular window as has been done is equivalent to convolving the impulse at $F=0$ (as the Fourier Transform of the DC signal) with a Sinc function (as the Fourier Transform of the rectangular window!). This is the sidelobes that occur for not only the DC signal, but any other signal at any other frequency location that would otherwise be an impulse in Frequency (so the tone at 0.5 Hz will also have sidelobes all scaled by the amplitude of that tone).

That said, below shows the plot of the DFT of the rectangular window that the OP had used, using the same number of samples that were used, as well as the same result with extending the number of samples out 10 times as much (importantly this was done by "zero-padding", meaning we only increased NFFT but we did not change the actual time length of the window which is still 100 seconds).

First a wider spectrum from -1 to + 1 Hz of just the DFT of the rectangular window over the same number of samples, sampling rate and duration as the OP used (although still a narrow part of the spectrum, the signal is sampled far higher than necessary which actually leads to further processing complexity; I would recommend that the OP change the sampling rate to 10 Hz which would be more than sufficient for this!). I have superimposed a longer zero-padded DFT to show that increasing the DFT length (but not changing the time duration of the window itself!) just serves to interpolate more samples in frequency of the underlying Sinc function as the Fourier Transform of the rectangular window (and once sampled with associated aliasing effects the Sinc becomes the "Dirichlet Kernel" but at such a high sampling rate appears very much as a Sinc here):

rectangular window Kernel

If we zoom in very close to $F=0$ we clearly see the shape of the Sinc, and how with the shorter DFT length that the OP chose results in samples on this same Sinc function (as the Fourier Transform of the Rectangular Window). We also see this very important takeaway: The first nulls for the main lobe of the Sinc appear at $f = 1/T$ where $T$ is the total time duration of the window in seconds! This is the reason that the strategy the OP should take (more important than using an improved window which also will help) is to increase the total time duration, which can readily be done with the same processing by decreasing the sampling rate (more on this later):

zoom in of rect window Kernel

It is this function that would convolve in frequency with the actual waveform, which is a tone at DC ($F=0$ Hz) and a smaller tone at $F = 0.5$ Hz. Given that the waveform has been multiplied by the rectangular window in time, then the result from the convolution will be a Sinc centered at $F=0$ and another Sinc centered at $F=0.5$ each weighted by their respective magnitudes. Below I plot the result of each separately, while the final result would be the sum (superposition) of each of these spectrums. We see, as the OP described, that the 0.5 Hz waveform is completely buried by the sidelobes from the rectangular windowing of the stronger DC signal.

waveform as two components

An immediate and obvious first strategy is to minimize the sampling rate and maximize the time duration to the extent that is possible. Once that is properly set further considerations can be made with using a different time domain window. I will first show the impact of changing the sampling rate to a more appropriate value. For the rectangular window, the sidelobes have first nulls at $f=1/T$ as I described, and their peaks will decrease at $1/f$. This means if we double the frequency the sidelobe will have gone down by -6 dB (we see this in the previous plot by comparing the sidelobe levels at $f=0.3$ Hz to $f = 0.6$ Hz). So similarly if we decreased the sampling rate from $f_s = 900$ to $fs = 10$ (which is sufficiently higher than our highest frequency of $f=0.5$ to not introduce significant aliasing effects), and correspondingly increase the time duration by $900/10 = 90$ we will have the same number of time samples but we will have reduced the sidelobe level at our frequency of interest (0.5 Hz) by $20 log_{10}(90) = 40$ dB. Inspecting the previous graph indicates that this would be more than enough and perhaps sufficient for a more immediate result without the further complexity of windowing (which I would still ultimately advise using, but my point here is the preeminence of this consideration in either case).

Spectrum with Sampling rate reduced to 10 Hz (and time duration extended by 90, same # of samples!) and we see directly the 40 dB predicted improvement:

sampled at 10 Hz

And zooming in on this new spectrum for direct comparison to the previous plot where the signal was buried:

zoom in fs = 10

And finally, showing what would traditionally be done which in addition to all first consideration above on minimizing sampling rate and maximizing time duration, is to multiply the time domain waveform with an improved window with the key property of having lower sidelobes than the rectangular window (but at the expense of losing frequency resolution: any window with lower sidelobes will have a wider main lobe). Below shows the end result with $f_s = 10 Hz$, $T = 9000$ and using a Kaiser Window, where the sidelobe is pushed down to -100 dB in vicinity of the waveform of interest!

Kaiser Windowed

  • $\begingroup$ Thanks for your in-depth answer! However, beyond the not optimal sampling, the doubt about the result of the band-pass filter still remain. In particular, if I filter a signal through a band-pass filter, this should consist in multiplying the spectrum of the signal with an ideally rectangular window whose limits are 0.2 and 0.8 Hz in my case. This should delete the big peak at f=0, but should not delete the sidelobes in the pass-band. Therefore, the desired tone should be buried in the filtered signal's spectrum, but surprisingly this does not happen. How can this be explained? $\endgroup$ Commented Feb 8, 2021 at 15:21
  • $\begingroup$ @LorenzoEboli I answered that in my first paragraph— but you are not correct in your assumption that it won’t delete the sidelobes as my answer explains. The filter removes the DC so there is no DC in your signal when you take the DFT, so there also won’t be any sidelobes. Please read through the rest of my answer as to the source of the sidelobes- it is not the DC signal but the window used in the DFT and it’s effect on all signals present (and as I said with your prefiltering, there is NO DC signal present). I hope that makes more sense now $\endgroup$ Commented Feb 8, 2021 at 15:25
  • $\begingroup$ For instance as I stated, simply subtract the average value (DC) and then take the DFT to also see how you eliminated that. $\endgroup$ Commented Feb 8, 2021 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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