Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

# Tag Info

85

Zero padding allows one to use a longer FFT, which will produce a longer FFT result vector. A longer FFT result has more frequency bins that are more closely spaced in frequency. But they will be essentially providing the same result as a high quality Sinc interpolation of a shorter non-zero-padded FFT of the original data. This might result in a ...

29

There are a few things to consider before you decide to zero pad your time-domain signal. You may not need to zero pad the signal at all! 1) Lengthen the time-domain data (not zero padding) to get better resolution in the frequency domain. 2) Increase the number of FFT points beyond your time-domain signal length (zero padding) if you would like to see ...

18

Resolution has a very specific definition in this context. It refers to your ability to resolve two separate tones at nearby frequencies. You have increased the sample rate of your spectrum estimate, but you haven't gained any ability to discriminate between two tones that might be at, for instance, 236 Hz and 237 Hz. Instead, they will "melt together" into ...

13

The term "resolution" has multiple meanings, which can confuse people trying to communicate when using two different meanings. In the optical sense, of being able to resolve two nearby clearly separated points (or two adjacent peaks in the spectrum) instead of one blurry blob, zero-padding won't help. This is the meaning most likely being used when ...

13

All that is happening when you zero-pad the input signal prior to a DFT, is that you are interpolating the frequency domain representation. For example, you might get a certain shape as the output of your absolute magnitude of the DFT, and this shape has 10 points. If you zero-padded the input of your DFT to say, 100 points, you will get the same shape as ...

9

Your problem is these two lines: t=(1:L)*(1/Fs); f=(1:L)*df; They should read: t=(0:L-1)*(1/Fs); f=(0:L-1)*df; If I modify your script as below (for scilab, not matlab), I get the following plot. The peaks all line up correctly. And the peak of the FFT is at 0.25 not 0.3125. for ZP=0:5 // of times of original length of signal to ZP with x=[...

8

In general zero-padding prior to DFT is equivalent to interpolation, or sampling more often, in the transformed domain. Here is a quick visualization of how the opposite works. If you sample a bandlimited signal in time at higher rate, you get a more 'squashed' spectrum, i.e. a spectrum with more zeros at both ends. In other words, you can obtain more ...

7

The thing to understand here is exactly what all your transforms and data fiddling do. We'll consider a 1D discrete-time signal which is rather easier to explain and think about. The arguments extend easily to higher dimensions. By taking the DFT of that signal, which has been windowed to a finite number of samples, N, to create a frame, one implicitly ...

7

Let's look at the frequencies of the bins in your 8-point DFT: $$\begin{array}{c} \omega_A = 0,\\ \omega_B = \pi/4,\\ \omega_C = \pi/2,\\ \omega_D = 3\pi/4,\\ \omega_E = \pi = -\pi\ ({\tt mod}\ 2\pi),\\ \omega_F = 5\pi/4 = -3\pi/4\ ({\tt mod}\ 2\pi),\\ \omega_G = 3\pi/2 = -\pi/2\ ({\tt mod}\ 2\pi), \\ \omega_H = 7\pi/4 = -\pi/4\ ({\tt mod}\ ... 7 The length N of the DFT is the number of frequency points that will result in the DFT output. Zero padding will result in more frequency samples, however this does not increase frequency resolution, it just interpolates samples in the DTFT. The frequency resolution is given by 1/T where T is the time length of your data (regardless of sampling rate). So ... 6 If one has any interest in the spectrum of the windowing function used to isolate the time-domain sample, then zero-padding WILL increase the frequency resolution of the windowing function. If the time signal is x(t)w(t), where w(t) is the windowing function, then the overall spectrum is X(f) * W(f), where * inidicates convolution. If your ... 5 I'd like to apply zero padding to it, for better frequency bin resolution. First of all, let's state it one more time that zero padding does not improve frequency resolution of DFT. It'll only interpolate the existing spectrum on a finer frequency grid, but will not add any new information to it, otherwise. In order to improve the true frequency resolution ... 4 There can be different reasons for this depending on any processes carried out before and after the Fourier transform. The most common reason is to achieve greater frequency resolution in any resulting transform. That is to say that, the larger the number of samples used in your transform, the narrower the binwidth in the resulting power spectrum. Remember: ... 4 It's actually possible to pre-multiply the signal with a complex exponential and thus shift the center frequencies of the FFT bins. Particular useful is multiplication that shifts by half a bin since it maintains complex conjugate symmetry for real valued time domain signals and you end up with N/2 complex at N/2 frequencies instead with N/2+1 frequencies ... 4 Advantages of zero padding: If length of your sequence doesn't correspond to the size that can be handled efficiently with FFT routine (usually powers of prime numbers) then you might want to add some extra zeros to the nearest power in order to get the maximum speed-up. In worst case you double the memory you need for your signal. Adding zeros is equal to ... 4 All effects you see have to do with windowing. Your signal can be seen as a truncated (i.e., rectangularly windowed) sinusoid. If s[n] is your signal, and w[n] is the window, the signal you analyze is$$\tilde{s}[n]=w[n]\cdot s[n]\tag{1}$$With the discrete-time Fourier transform (DTFT) defined by$$S(f)=\sum_{n=-\infty}^{\infty}s[n]e^{-j2\pi nf}\tag{...

4

The result of a convolution of a data vector of length M with a kernel of length G is of length M + G - 1. (the maximum length of the non-zero portion, even though the limits of integration is sometimes written as from -infinity to +infinity) This is clearly (G - 1) elements longer than the original data vector. So where do these new, "extra", additional ...

3

Zero padding in the time domain corresponds to interpolation in the frequency domain (and vice versa). The specific relationship is sync interpolation, sometimes also known as Whittaker-Shannon interpolation. http://en.wikipedia.org/wiki/Whittaker%E2%80%93Shannon_interpolation_formula In case of the FFT the linear integral/sum has to be replaced with a ...

3

Shifting the data points (fftshift) and zero-padding the exact center of the FFT aperture has the property that all the even (symmetric) components with reference to the center of the original data set end up in the real part of the complex FFT result, and all the odd components end up in the imaginary part. e.g. the evenness to oddness ratio is preserved, ...

3

I know this is old, but I thought I would add something here. You can smoothly blend the part the filtered and unfiltered segments with a gradual function such as a sinusoidal window function. That will make this a little more agnostic to the type of input function since it will retain the original, unprocessed function at the boundaries yet leave less ...

3

Can there be any changes made in the above method to solve this boundary problem? Yes there can be, but it all depends what you want to occur at the boundary. If you don't want it to be smoothed then simply replace the edge with the original signal for a sensible number of samples, depending on the width of your gaussian. You gaussian might be > 0 for say ...

3

For a) you're correct. For b), $x_1$ is a length $2N$ signal, and its DFT is given by $$X_1[k]=\sum_{n=0}^{2N-1}x_1[n]e^{-j2\pi kn/2N}=\sum_{n=0}^{2N-1}x_1[n]e^{-j\pi kn/N}\tag{1}$$ With $x_1=x[n]+x[n-N]$ you get \begin{align}X_1[k]&=\sum_{n=0}^{N-1}x[n]e^{-j\pi kn/N}+\sum_{n=N}^{2N-1}x[n-N]e^{-j\pi kn/N}\\&=X\left(e^{j\pi k/N}\right)+\sum_{n=0}^... 3 The conventional definition of the DFT for a length N signal (without zero-padding) isX[k]=\sum_{n=0}^{N-1}x[n]e^{-j2\pi nk/N}\tag{1}$$So there is no scaling involved. Scaling is applied to the inverse DFT:$$x[n]=\frac{1}{N}\sum_{k=0}^{N-1}X[k]e^{j2\pi nk/N}\tag{2}$$If you pad a length N signal with M zeros, the resulting DFT length is ... 3 so let's say the length of your FFT is N. let's say that you fill half of the buffer with your signal and fill the other half with zeros.$$ x[n] = 0 \quad \text{ for } \tfrac{N}2 \le n < N $$the DFT of x[n] is X[k]. then magnitude-square and inverse DFT:$$ R_x[n] = \mathcal{iDFT}\bigg\{ \bigg|X[k]\bigg|^2 \bigg\} $$in the time domain, ... 3 Think about both questions separately. First of all, the (I)FFT is just an implementation of the (I)DFT, so I'm going to generalize all this to the DFT. Does the zero-padded IDFT retain variance? Parseval's theorem says power out = constant factor · power in, and the power of the zero-padded sequence is the energy of that sequence divided by it's length – ... 3 The math is well known; it is the convolution theorem for the DFT. In this specific case:$$DFT\left\{f[n]\cdot z[n]\right\} = DFT\left\{f[n]\right\} * DFT\left\{z[n]\right\} Where: $f[n]$ denotes your original sequence of 128 samples $z[n]$ denotes a sequence of 128 samples, each randomly selected from $\{0,1\}$ '$*$' denotes cyclic convolution, ...

3

Use the second one Tony... It yields the correct implied phase relationship.

2

I did not see these mentioned in the prior good responses so I will add the following additional important reasons for zero padding: Radix-2 algorithms are more efficient so zero padding out to the next power of 2 (or power of 4 in some cases for radix-4), or more significantly avoiding any large prime factors can improve real time performance. Also when ...

2

There are many ways to interpolate data. Interpolation in my mind means that you 'draw' lines between some data points. This can be done many ways. One type of interpolation which is useful in DSP (especially in multirate DSP) is 'Bandlimited interpolation'. If you google that you will get many interesting and useful hits. What you propose is not bandlimited ...

2

Zero padding is a useful interpolation tool using sinc function (or kernel). I will below explain it in 3 parts. First: what is DFT; Second: Zero-padding; Third: Usage of zero-padding. (a) $\textbf{What is DFT}$: By taking a DFT of a data set we are mapping the data values from the current discrete domain (many case happens to be time example in audio ...

Only top voted, non community-wiki answers of a minimum length are eligible