Prev: CFP: The 2010 International Conference on Data Mining (DMIN'10), USA, July 2010
Next: FFTW Power Spectrum
From: dbd on 6 Feb 2010 14:36 On Feb 6, 8:19 am, Jerry Avins <j...(a)ieee.org> wrote: > ... > Hint: the answer depends on the > sampling frequency and the time interval. Zero padding effectively > doubles the sample rate. > > Jerry Jerry I think you have the right idea, but a confusing explanation of it. Zero padding doesn't change the sample frequency Fs or the time interval 1/Fs. Zero padding to double the length halves the frequency domain sample interval from Fs/N to Fs/2N. I tried to say that without the term "sample rate" because "sample rate" has different interpretations in time and frequency domains. Dale B. Dalrymple
From: Jerry Avins on 6 Feb 2010 14:40 dbd wrote: > On Feb 6, 8:19 am, Jerry Avins <j...(a)ieee.org> wrote: >> ... >> Hint: the answer depends on the >> sampling frequency and the time interval. Zero padding effectively >> doubles the sample rate. >> >> Jerry > > Jerry > > I think you have the right idea, but a confusing explanation of it. > > Zero padding doesn't change the sample frequency Fs or the time > interval 1/Fs. Zero padding to double the length halves the frequency > domain sample interval from Fs/N to Fs/2N. > > I tried to say that without the term "sample rate" because "sample > rate" has different interpretations in time and frequency domains. You're probablt right. I tried to get across that the zero padding doubled the number of samples without changing the time. "Sample rate" was a poor choice. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
From: Fred Marshall on 7 Feb 2010 00:41 It looks to me that Grant came the closest to explaining: You start with 1 sec of a 1Hz sine - so it is exactly a single period. There are no abrupt changes incurred in doing this as it is assumed that this one period of a periodic waveform (which is your intent as well!). You sample at 1kHz. Just to be complete: The sample interval in frequency for the FFT is 1Hz due to the 1sec temporal interval. By luck, happenstance or design, there is a sample point of the FFT at exactly 1Hz - which coincides with the original signal. So, you see samples at 1Hz and at 1023Hz (which is 1024Hz=Fs minus 1Hz). Next, you pad zeros to the original temporal sequence. Now the assumed period has a single sine cycle and a zero-valued segment of equal length for a total "period" of 2sec. It's pretty easy to see that this is no sine wave but, rather, a sine wave that has been alternately zeroed and not zeroed cycle by cycle. It's as if you mulitplied the temporal record by a "gate wave": 1 for 1sec then 0 for 1 sec, 1 for 1sec then 0 for 1 sec...... The "gate wave" has a Fourier Transform that is a periodic sinc or Dirichlet. Because of it's particular character it's alternately zero and non-zero valued and the non-zero values alternate in sign except at the peaks which are nonzero for 3 samples. Because you multiplied the sine by the "gate wave" in time, you have effectively convolved their spectra together in frequency. Thus, the nice pair of nonzero samples in frequency now have been convolved by this sampled Dirichlet. Thus all those nonzero results in frequency. They effectively represent the energy in the abrupt changes when the sinusoid goes to zero and vice versa. You asked why, if zero padding isn't supposed to add information, then why does this happen? Here's the answer: Presumably the sinusoid is adequately sampled. And, in the first case it is. Zero padding in time will add samples in frequency and in the second case that's what happened. But, the first case was rather contrived because it matched the underlying period exactly and there was no discontinuity introduced.. In fact, there could have been more "information" available but had been hidden. If you had used 3.14 Hz or some such instead then you'd have seen the effect of the discontinuities at the end. I hope this helps. Fred
From: Jerry Avins on 7 Feb 2010 14:46 rsk wrote: >> On 6 Feb, 11:16, "rsk" <kalera...(a)yahoo.com> wrote: >>> . Philosophically speaking, I think the sine wave and zero >>> padded sine wave are two different signals and hence they should show >>> different spectrum. However, it is commented in many articles that the > zero >>> padding adds no more information. My intention was just to check this. > And, >>> I am still confused with the outcome. >> You changed the signal in a deterministic way, which means that >> you didn't learn anything new about whatever process generated >> the data. >> >> In this sense you added no information. >> >> But the linear computations work on two different sets of data, >> which means the outcomes must be different. >> >>> Did you mean, even if I got 0.5 Hz as >>> the frequency, it is actually 1 HZ?. >> What makes you think that there are fixed frequency labels? >> There aren't. Read up on the basics. >> >>> Also, why did the amplitude change? >> Read up on the basics. >> >> Rune >> > > I am certainly going through basics. Just not finding right explanation. > > Brigham in his book says(page 173) > > "FFT resolution can not be enhanced by appending zeros unless the function > is in fact zero valued over the interval where the zeros are appended" And Grant, in his wisdom tole you to interpret that to mean that it adds no information to the original data. > his statement is somewhat confusing. If I zero pad a function, I can call > it as a new function that is zero valued over that interval. Then, it can > affect the resolution!. This is exactly what I tried in my sine wave > example. Sure. You can also just make up new points to plot. They don't tell you any more than you already knew. > When I asked this, >>> Did you mean, even if I got 0.5 Hz as >>> the frequency, it is actually 1 HZ?. > I was referring to reply by Suren given below > "since the new bin location, is at > twice the original bin location, the actual frequency is still 1 Hz." It was actually 1 Hz. The bin labels change when you change the number of FFT input data points. Read *all* the replies. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
From: Greg Heath on 7 Feb 2010 15:41
On Feb 5, 11:03 am, "rsk" <kalera...(a)yahoo.com> wrote: > All > > This might have been discussed multiple times. However, I am new comer to > the site. > > My question is given below. I wanted to put plots but could not find the > way to do it. > > I took a sine curve from 0-1 s( 1Hz)and 'fft'ed it in MATLAB. I get unit > magnitude at 1 Hz as expected. Sampling rate 1024. Signal freqency and period are f0 = 1Hz, T0 = 1/f0 = 1sec. Sampling interval and times for 1 period are dt = 1/Fs, t = 0:dt:T-dt; T = T0. Note that max(t) = T -dt < 1sec. Number of time sampling points are N = T/dt = 1024 ( t = dt*(0:N-1); ), Sampling interval and freqencies for 1 fft period are df = 1/T = Fs/N and f = df*(0:N-1); = 0:df:Fs-df; If you use MATLAB, Z = fft(z/N); , z = cos(2*pi*f0*t); will yield max(abs(Z)) = 0.5 at f(2) = f0 = 1 and f(1024) = Fs-f0 = 1023 > Then I zero padded it till 2 sec. So, total lines = 2048. > The fft then showed major peak(0.5 magnitude) at 2 Hz with > other higher frequencies present. z2 = [z zeros(1,N)]; N2 = 2*N, df = Fs/N2 = df/2 f2 = df2*(0:N2-1); = (df/2)*(0:2*N-1); Now, Z2 = fft(z2/N2) will yield max(abs(Z2)) = 0.5 * maxabs(Z)) = 0.25 at f2(3) = f0 = 1 and f(2047) = Fs-f0 = 1023. Therefore, the peaks of Z2 are at the same frequencies. However, the magnitude of the peaks are lower by a factor of 2 because the average power is a factor of 2 lower. This raises questions about the correct fft scaling for comparing zero-padded and periodically continued functions. For example, comparing z3 = [ z z]; z4 = [zeros(1,M) z zeros(1,N-M)]; > All articles on zero padding say that, zero padding > does not add more> information but just makes existing > information more fine. Going by that, the fft in second > case should also have shown peak at 1 Hz. May I know > where did I go wrong? N2 = 2*N but Fs2 = Fs, therefore df2 = Fs2/N2 = df/2. > In Summary, should there be a difference in the usual > sine wave and zero padded sine wave with respect to > frequency spectrum? Yes, because their periodic continuations are different. In particular, there will be rectangular window convolution effects. However, comparing the spectra of functions with different lengths doesn't seem kosher. It makes more sense to compare Z2 and Z3 = fft(z3/N2). Neither contains additional information and the reason for the factor of 2 reduction becomes obvious. If w = [ones(1,N) zeros(1,N)]; then (using element-wise multiplication) z2 = w.*z3; = w.*[ z x]; for arbitrary x Hope this helps. Greg |