Forums

Zero padding fftw

Started by simwes December 8, 2010
 Hello everybody

I am writing a code to transform an array from the frequency domain to time
domain using the fftw. In order to increase the resolution of the signal in
the time domain I am adding zero in the frequency before sending it to the
fftw.
The problem is that the signal in the time domain shifts as I add zero in
the array in the frequency domain! I don't understand why!
Please can someone help me?

Thank you very much!


On 12/08/2010 10:23 AM, simwes wrote:
> Hello everybody > > I am writing a code to transform an array from the frequency domain to time > domain using the fftw. In order to increase the resolution of the signal in > the time domain I am adding zero in the frequency before sending it to the > fftw. > The problem is that the signal in the time domain shifts as I add zero in > the array in the frequency domain! I don't understand why! > Please can someone help me? > > Thank you very much!
How is the signal shifting? I assume that you are adding more than one zero -- how many zeros are you adding, and where? -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On Dec 8, 1:23&#2013266080;pm, "simwes" <olivetti81@n_o_s_p_a_m.libero.it> wrote:
> &#2013266080;Hello everybody > > I am writing a code to transform an array from the frequency domain to time > domain using the fftw. In order to increase the resolution of the signal in > the time domain I am adding zero in the frequency before sending it to the > fftw. > The problem is that the signal in the time domain shifts as I add zero in > the array in the frequency domain! I don't understand why! > Please can someone help me? > > Thank you very much!
You want to fill in symmetrically about the DC point. Clay
On Dec 8, 11:23&#2013266080;am, "simwes" <olivetti81@n_o_s_p_a_m.libero.it> wrote:
> &#2013266080;Hello everybody > > I am writing a code to transform an array from the frequency domain to time > domain using the fftw. In order to increase the resolution of the signal in > the time domain I am adding zero in the frequency before sending it to the > fftw. > The problem is that the signal in the time domain shifts as I add zero in > the array in the frequency domain! I don't understand why! > Please can someone help me? > > Thank you very much!
I propose experiment: 1. Take your frequency array and zero out all the imaginary elements in the array. 2. Now translate this back to time signal and see what it looks like 3. Add zero padding 4. Now see if you still get the shift problem when you compare answer to #2. Sincerely, Victor Vector
simwes <olivetti81@n_o_s_p_a_m.libero.it> wrote:
 
> I am writing a code to transform an array from the frequency domain to time > domain using the fftw. In order to increase the resolution of the signal in > the time domain I am adding zero in the frequency before sending it to the > fftw.
> The problem is that the signal in the time domain shifts as I add zero in > the array in the frequency domain! I don't understand why! > Please can someone help me?
Next time you go to the bank, ask for your withdrawal in all pennies. (or equivalent in other countries). It will look like you are gettting more money out, but actually it is the same. Zero padding can make it look like you are getting more resolution, but you can't create resolution that isn't there in the first place. -- glen
On 12/8/2010 10:23 AM, simwes wrote:
> Hello everybody > > I am writing a code to transform an array from the frequency domain to time > domain using the fftw. In order to increase the resolution of the signal in > the time domain I am adding zero in the frequency before sending it to the > fftw. > The problem is that the signal in the time domain shifts as I add zero in > the array in the frequency domain! I don't understand why! > Please can someone help me? > > Thank you very much! > >
Sometimes increasing the *apparent* resolution like this is needed for things like plotting or ... whatever. Just don't be deceived into thinking that the resolution is actually improved. Consider this: Start with a time domain sequence of N samples, sample interval T, duration (N-1)*T which is even and centered on t=0 and is zero at the ends and the number of nonzero samples is even. This means that the sequence will be nonzero at index aligned with t=0 and nonzero (assumed) at NT and will have zero-valued samples equally arrayed around NT/2. (It's just a lot easier to know if there's a time shift if the sequence is centered at t=0). Compute the FFT. It will be real and even. From this, you can likely work out what happens if the time sequence isn't even and the spectrum is complex. Like this: original Samples <-> Original spectrum x x | | x | | x x x | | x x | | |x x| | | | | | | | x x | | | | | | | | x x | | | | | | | | x x | | | | | | | | x x | | | | | | | <-> | x x | | | | | | | | x x | | | | | | | | | x x | | | | | | | | | x x | | T | T | T | T | T | T | | x xx x | | | | | | | | | x x x x | +-----------o-----------+ +-----------xx----x-----------+ 0 (N-1)T 0 fs time -> frequency -> fs=1/T Now, in order to introduce a pure time shift S, you would multiply the spectrum by e^-jwS <> f(t-S). But, I don't think you did that.... In order to keep the time domain sequence real and even thus centered at t=0, you need to keep the spectrum samples real and even, so introduce the zeros at fs/2. You would do the same thing effectively in the time sequence in order to interpolate the spectrum samples. If you keep the time domain sequence real and even then I don't see how you would observe a time shift. In effect, you are doing this (for an interpolation factor of 2): Extend the spectral samples out to 2fs by repeating the samples. Lowpass filter the spectral samples so as to remove the spectral "bump" around fs. Now you have the same spectrum around f=0 as before but with double the sample rate. What you're doing is the "shorthand" version by simply plugging in zeros where the filter would have reduced the samples to (nearly) zero. Fred
On Dec 8, 1:23&#2013266080;pm, "simwes" <olivetti81@n_o_s_p_a_m.libero.it> wrote:
> &#2013266080;Hello everybody > > I am writing a code to transform an array from the frequency domain to time > domain using the fftw. In order to increase the resolution of the signal in > the time domain I am adding zero in the frequency before sending it to the > fftw.
This is fourier interpolation. This does not increase resolution. The only way to increase resolution is to increase the originak time sampling rate.
> The problem is that the signal in the time domain shifts as I add zero in > the array in the frequency domain! I don't understand why! > Please can someone help me?
The zeros have to be symmetric about the Nyquist frequency. The exact formula depends on whether N is even or odd. Hope this helps. Greg
On Wed, 8 Dec 2010 19:39:21 -0800 (PST), Greg Heath
<heath@alumni.brown.edu> wrote:

>On Dec 8, 1:23=A0pm, "simwes" <olivetti81@n_o_s_p_a_m.libero.it> wrote: >> =A0Hello everybody >> >> I am writing a code to transform an array from the frequency domain to ti= >me >> domain using the fftw. In order to increase the resolution of the signal = >in >> the time domain I am adding zero in the frequency before sending it to th= >e >> fftw. > >This is fourier interpolation. This does not increase >resolution. The only way to increase resolution is to >increase the originak time sampling rate.
Not really. Resolution is increased by increasing the observation time. This means either increasing the number of samples in the FFT window, or sampling more slowly.
> >> The problem is that the signal in the time domain shifts as I add zero in >> the array in the frequency domain! I don't understand why! >> Please can someone help me? > >The zeros have to be symmetric about the Nyquist >frequency. The exact formula depends on whether N >is even or odd. > >Hope this helps. > >Greg
Eric Jacobsen Minister of Algorithms Abineau Communications http://www.abineau.com
On 12/8/2010 7:59 PM, Eric Jacobsen wrote:

> Not really. Resolution is increased by increasing the observation > time. This means either increasing the number of samples in the FFT > window, or sampling more slowly. > >>
Yabut .... in this case the interpolation is in time. So, increasing the sample rate is the frequency dual of increasing the observation time. And, since the sample rate is fixed, doubling the sample rate replicates the spectrum is all - so no new information. Fred
On Dec 8, 10:39&#2013266080;pm, Greg Heath <he...@alumni.brown.edu> wrote:
> On Dec 8, 1:23&#2013266080;pm, "simwes" <olivetti81@n_o_s_p_a_m.libero.it> wrote: > > > &#2013266080;Hello everybody > > > I am writing a code to transform an array from the frequency domain to time > > domain using the fftw. In order to increase the resolution of the signal in > > the time domain I am adding zero in the frequency before sending it to the > > fftw. > > This is fourier interpolation. This does not increase > resolution. The only way to increase resolution is to > increase the originak time sampling rate. > > > The problem is that the signal in the time domain
shifts as I add zero in
> > the array in the frequency domain! I don't understand
why!
> > Please can someone help me? > > The zeros have to be symmetric about the Nyquist > frequency.
Clarification: The zeros have to maintain the symmetry.
> The exact formula depends on whether N > is even or odd.
If N is odd [ X(1:(N+1)/2)) zeros(1,M) X((N+3)/2:N) ] If N is even [ X(1:N/2) 0.5*X(N/2+1) zeros(1,M) ... 0.5*X(N/2+1) X(N/2+2:N) ] Hope this helps. Greg