Tuesday, 28 April 2015

matlab - FFT Zero Padding - Amplitude Change


I'm just learning about Fourier Transforms and as an input I'm using a WAV file (Matlab) and taking one channel of it and performing a quick Fourier transform. I've zero padded the input, as I've been told that it gives a better frequency resolution. I've done this and I see an identical looking graph apart from that the magnitude has changed. Could somebody please explain to me why the magnitude has decreased and is their any linearity to how it changes?


I assume that the frequencies will be similar to those before the zero padding but just be a better fit?




Answer



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 signals; it can also be spatial co-ordinates as for images) to a discrete frequency domain. With the transform doing this mapping being a matrix (hence linear) which is always full-rank the mapping is always invertible without any loss in information content. Example we can take idft of the obatined dft and get back the same data we started with again or no loss!


Why go to this other domain (so called transform (here frequency) domain) of representing the same data? Well, (a real life note) when we are trying to make decisions we want to see the facts clear in front of us. We don't want unnecessary facts and likes and dislikes to wander in our mind. It similar in signal processing. When we want to analyze data we want to see the data in such a domain of representation where we have,



  • concentration of information only in localized points in that domain

  • the domain gives some sort of a physical interpretation to the data we have (this is a super plus point)


Thus it is clear by using DFT we want see if we can gain from the above two. Of course, if the data has one of the columns of the DFT matrix itself we have gained the maximum out of the DFT domain based representation i.e only one point in the mapped domain values will have a non-zero value ideally. Now suppose the signal is not representable using any one of the columns of the DFT matrix. Then DFT will try to represent the data by a minimal number of mixture of the columns of the DFT matrix i.e only few of the mapped domain values will have a non-zero values. So, which type of data will do this: those which share some characteristics with the DFT matrix columns such as are periodic. $A\ moral$: hence DFT is good to represent periodic data as it gives a minimal representation based on number of non-zeros values (magnitude captures the contribution of each column in making up the original domain data).


(b)$\textbf{ Zero-padding}$: In zero-padding we have first padded zeros to the data in the original domain and then take the new zero-padded signal's DFT. This means by zero-padding we have increased the number of columns in the DFT matrix (with the matrix now also being orthogonal) with no new data in the original domain being added. With this we can hope to see more in deep how much the new added columns contribute in representing the time-domain signal. Note what we earlier say with N-point DFT will also see the same at those N points in a subsequent 2N-point DFT of the same data. So the peak magnitude will not change. (Considering we are not normalizing the DFT matrix). Now when we take the iDFT normalization factor comes into picture and we have to normalize by 1/2N this time to get the same data back instead of by N in the previous case and not pick only N points in the 2N point data. The zero-padding in time-domain can also be interpreted as sinc interpolation in the DFT domain to get the contribution of the newly introduced columns in the 2N-pont DFT. This needs a separate post of detail description. But you can see it easily by drawing the signal and seeing the zero-padded signal as a multiplication of the original assumed to be 2N length signal with a rectangular window which results in convolution in the frequency domain with a sinc function. It may be clear now that we are not increasing frequency resolution by zero-padding i.e we are not resolving two frequencies close by but we are filling new frequencies between the existing N-point DFT frequencies and finding their contributions for making the signal. Frequency resolution can be increased only by sampling the data more finely or taking new data points which is in our hand only if we are an experimenter.



(c) $\textbf{Applications of zero-padding}$: It is used as a frequency domain interpolation tool for getting the side lobe structure for filters. Also it is used to interpolate (or re-sampling) in time domain by zero-padding in frequency domain. Zero-padding in frequency domain needs care so as to preserve the original phase of the signal.


Hope this post is clear. May have a lot of redundancy if you already know much of it.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...