4
$\begingroup$

I sample a signal at a certain frequency for a finite amount of time to get a sequence $$(x_n)_{n=1}^N = (x_1, x_2, ... , x_N)$$

with the intention of analyzing its power spectral density by calculating its DFT.

I decide that the tail end of the sequence shouldn't be analyzed (that is, I want to discard all $x_n$ for $n\gt a$ for some $a\leq N$), but I want the DFT to have the same number of samples (in this case, $N$ samples).

One approach would be to truncate the sequence at $x_a$, remove the mean, apply a Hamming window to this truncated sequence, pad the truncated sequence with $N-a$ zeroes, and then calculate its DFT.

Question: Let's say that the section I don't want to analyze is an interval in the middle of the sequence. How do I calculate the DFT of this and make sure the DFT has $N$ samples? Should I remove the mean, apply two Hamming windows (one each on each section I don't want to discard), set the elements in the middle that I want to discard to zero, and calculate the DFT?

This is related to my other question here.

$\endgroup$
3
  • $\begingroup$ Why you remove the mean? This is the DC component - is it limiting the dynamic range of the calculation? Do you mean DFT or FFT? What is the incentive of removing meaningful information intentionally in the middle of the sequence - if it is not contributing does it men you look only for high frequencies? $\endgroup$
    – Moti
    Commented Jul 13, 2016 at 19:06
  • $\begingroup$ @Moti I remove the mean to minimize the discontinuity between the original sequence and the zero-padded section, as the Hamming window is more effective in this case.I do not care to analyze the first element of the DFT sequence (DC component), and this is the only element that is affected by removing the mean. The FFT is the algorithm used to calculate the DFT. The information I am removing from the middle of the original sequence is precisely not meaningful, hence the removal. Think of it as a sensor falling out of place in the middle of a recording, and having to account for that. $\endgroup$ Commented Jul 15, 2016 at 21:15
  • $\begingroup$ Than I would suggest to evaluate each group separately - avoiding the padding will provide you a cleaner spectral result. May be that it will better for you not to use the FFT for evaluation, depending on the specifics of sampling and number of samples.. $\endgroup$
    – Moti
    Commented Jul 15, 2016 at 23:59

2 Answers 2

3
$\begingroup$

If there's a region in the middle of the sequence that you want to discard, you can't just set those samples to zero and compute the DFT, because the DFT would reflect the fact that your sequence suddenly jumps to the value zero, and then suddenly jumps back again to non-zero values. So the zero values would significantly contribute to the result of the DFT, which is almost the opposite of what you want to achieve.

What you should do is consider the two relevant parts at the beginning and at the end as two realizations of the underlying process, and compute two DFTs, which can then be averaged, just like in Bartlett's method. Of course, each sub-sequence can (and should) be windowed and zero-padded before computing the DFT.

$\endgroup$
2
  • $\begingroup$ Do I have to account for the size of the relevant parts? If they each contain a different number of samples (but the same after zero-padding), should I be considering a weighted average? $\endgroup$ Commented Jul 15, 2016 at 16:41
  • $\begingroup$ @AdamFrancey: That would probably make sense. $\endgroup$
    – Matt L.
    Commented Jul 15, 2016 at 18:43
1
$\begingroup$

The transform of a rect rotated in a DFT window so it wraps around the window edges is still a Sinc in magnitude. So the effect (Sinc convolution) will be the same as zero padding on just one side of a data vector, except the Sinc will be twisted in phase. But the twist will be coherent (the DFT basis vectors won't be broken). Thus, the advantage of rotating a rect around a FFT aperture to zero pad the middle of a vector is that the longer FFT will give you coherent gain over just using 2 shorter FFTs + Welch or Bartlett summing.

This coherent gain may or may not be meaningful, depending on whether the underlying signal portions are together coherent or not. If the middle of your signal is corrupted by a strong interfering signal burst or ionospheric dropout, your signal of interest might be coherent across the gap. But two separately played musical notes are unlikely to be so.

For narrowband signals that are narrower than the bin separation of DFT result of just the short segments, but are coherent together over a longer time interval, using the phase vocoder algorithm is another method of getting coherent gain for improved spectral frequency estimation from multiple short FFTs. Phase vocoding is usually done with overlapping FFT windows, but the theory works the same for separated windows as long as the sampling clock (and data!) stays strongly synchronized over the total longer time interval. So using separated Von Hann (etc.) windows over portions of a signal and then using a longer FFT across all of the windows may be related to an efficient method of phase vocoding across an entire DFT spectrum.

$\endgroup$
4
  • $\begingroup$ I don't think this is true: That it would still be a sinc function; just compare the two in Matlab/Octave: freqz([1 1 1 1 1 1 1 1 1 1 0 0 0 0 0]) to freqz([1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1]) and you can see that the magnitude as well as phase is immediately distorted by the rotation. $\endgroup$ Commented Jul 10, 2016 at 19:54
  • $\begingroup$ Look up the time-shift or time shifting property of the FFT. $\endgroup$
    – hotpaw2
    Commented Jul 11, 2016 at 0:25
  • $\begingroup$ I see now, thank you. My err was to test quickly with freqz instead of fft directly; freqz pads out the fft to a longer number of samples (so computed the fft of two very different cases as opposed to a simple rotational shift). $\endgroup$ Commented Jul 11, 2016 at 0:57
  • $\begingroup$ Interesting, with the time-shift property it can be shown that the magnitude of the DFT is the same if I time-shift the zero-padded middle to the end of the sequence. $\endgroup$ Commented Jul 15, 2016 at 16:45

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.