Hello forum, can someone clarify for me , once again, what zero padding is good for? To my understanding the frequencies in the DFT are integer multiples of f_s /N (where f_s is the sampling frequency). So the interval between neighbouring frequencies is Delta_f= f_s/ N. The bigger N, the higher the resolution, because the smaller Delta_f. But I hear that zero padding does not actually increase resolution.... Confused. Thanks fisico30
zero padding once again
Started by ●February 12, 2009
Reply by ●February 13, 20092009-02-13
On Feb 12, 4:16 pm, "fisico30" <marcoscipio...@gmail.com> wrote:> Hello forum, > > can someone clarify for me , once again, what zero padding is good for? > To my understanding the frequencies in the DFT are integer multiples of > > f_s /N (where f_s is the sampling frequency). > > So the interval between neighbouring frequencies is Delta_f= f_s/ N. > The bigger N, the higher the resolution, because the smaller Delta_f. > But I hear that zero padding does not actually increase resolution.... > Confused. > > Thanks > fisico30if f_s =1000 and N = 10, resolution will be 100Hz, but what if you want 106Hz resolution and you only have N power FFTs, zero padding solves this problem
Reply by ●February 13, 20092009-02-13
On 13 Feb, 01:16, "fisico30" <marcoscipio...@gmail.com> wrote:> Hello forum, > > can someone clarify for me , once again, what zero padding is good for? > To my understanding �the frequencies in the DFT are �integer multiples of > > f_s /N �(where f_s is the sampling frequency). > > So the interval between neighbouring frequencies is Delta_f= f_s/ N. > The bigger N, the higher the resolution, because the smaller Delta_f. > But I hear that zero padding does not actually increase resolution.... > Confused.The confusion occurs because 'resolution' means different things in different contexts. Zero padding causes the spectrum coefficients to become denser in frequency domain, which might be seen as 'increasing the resolution'. However, this does not mean that the spectrum shows more than it does without the zero-padding. In other contexts 'resolution' means 'separating two sinusoidals that have similar frequencies.' In this case, the question how to separate the two sines and recognize them as different. Zero-padding does not help with this. Below is a matlab script that illustrates a few of the concepts. If you run it, you will get three grapchs. Graph a) shows how the spectrum is interpolated by zero-padding: There are just a few more 'dots' in the graph, but the basic graph is the same. Panel b) shows a spectrum where thre are two sines, at f1 = 0.14 and f2 = 0.2 (the green spikes). If you have N=8 samples in your data sequence, the basic spectrum (blue) does not resolve the sines, nor does the zero-padded spectrum (red). However, if you have enough data in the first place (N=32) then both the basic and the zero-padded spectrum separate the signals, as in panel c). In this case zero-padding is helpful with locating exactly where the spikes are, which is yet another possible meaning for the term 'resolution'. So the problem is that the terminology is ambiguous. You need to understand the different concepts of 'resolution' and then make sure you understand exactly what is meant when you see or hear the term 'resolution'. And be aware that whoever you are talking with might not be aware of such subtle differences in terminology. Rune %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all fs = 1; N = 8; tv = (0:N-1)/fs; f = 0.125*fs; x=sin(2*pi*tv*f); fv =(0:N-1)*fs/N; X = fft(x); Nfft = 32; fvzp=(0:Nfft-1)*fs/Nfft; Xzp=fft(x,Nfft); clf subplot(3,1,1) stem(fvzp,abs(Xzp),'r'); hold on stem(fv,abs(X),'b'); title('a) Spectrum Interpolation by Zero Padding') y = sin(2*pi*tv*0.14)+sin(2*pi*tv*0.2); Y=fft(y); Yzp = fft(y,Nfft); subplot(3,1,2) stem(fvzp,abs(Yzp),'r'); hold on stem(fv,abs(Y),'b'); stem([0.14,0.2,0.8,0.86],4*[1 1 1 1],'g') title('b) Zero-padding does *not* resolve spikes') N = 32; tv = (0:N-1)/fs; z = sin(2*pi*tv*0.14)+sin(2*pi*tv*0.2); fv =(0:N-1)*fs/N; subplot(3,1,3) Z = fft(z); Nfft = 128; fvzp=(0:Nfft-1)*fs/Nfft; Zzp=fft(z,Nfft); stem(fvzp,abs(Zzp),'r'); hold on stem(fv,abs(Z),'b') stem([0.14,0.2,0.8,0.86],16*[1 1 1 1],'g') title('c) Sufficient data *does* resolve spikes')
Reply by ●April 21, 20092009-04-21
Hello Rune, thanks again for the clarification on zero padding and resolution. So, semantics aside, zero padding does 1) not change the form of the spectrum (good) 2) not change the total bandwidth of signal (good) 3) add new, more frequency values to the FFT. These values are interpolated values that make the spectrum look better, more continuous. But, in my mind, resolution means getting more values, see deeper, more precisely. And that seems to be what zero padding does. We can argue if interpolated values are just estimations ( not as truthful as real data). However, to me it seems that zero padding actually increases resolution. IF not, I am wrong again. What causes then an increase in resolution? Same data length but faster sampling (more data samples)? thanks again marco>On 13 Feb, 01:16, "fisico30" <marcoscipio...@gmail.com> wrote: >> Hello forum, >> >> can someone clarify for me , once again, what zero padding is goodfor?>> To my understanding =A0the frequencies in the DFT are =A0integermultiple=>s of >> >> f_s /N =A0(where f_s is the sampling frequency). >> >> So the interval between neighbouring frequencies is Delta_f=3D f_s/ N. >> The bigger N, the higher the resolution, because the smaller Delta_f. >> But I hear that zero padding does not actually increase resolution.... >> Confused. > >The confusion occurs because 'resolution' means different >things in different contexts. Zero padding causes the spectrum >coefficients to become denser in frequency domain, which >might be seen as 'increasing the resolution'. However, this >does not mean that the spectrum shows more than it does without >the zero-padding. > >In other contexts 'resolution' means 'separating two sinusoidals >that have similar frequencies.' In this case, the question how >to separate the two sines and recognize them as different. >Zero-padding does not help with this. > >Below is a matlab script that illustrates a few of the concepts. >If you run it, you will get three grapchs. Graph a) shows how >the spectrum is interpolated by zero-padding: There are just a >few more 'dots' in the graph, but the basic graph is the same. > >Panel b) shows a spectrum where thre are two sines, at f1 =3D 0.14 >and f2 =3D 0.2 (the green spikes). If you have N=3D8 samples in your >data sequence, the basic spectrum (blue) does not resolve the >sines, nor does the zero-padded spectrum (red). > >However, if you have enough data in the first place (N=3D32) >then both the basic and the zero-padded spectrum separate >the signals, as in panel c). In this case zero-padding is >helpful with locating exactly where the spikes are, which >is yet another possible meaning for the term 'resolution'. > >So the problem is that the terminology is ambiguous. You >need to understand the different concepts of 'resolution' >and then make sure you understand exactly what is meant >when you see or hear the term 'resolution'. > >And be aware that whoever you are talking with might not >be aware of such subtle differences in terminology. > >Rune > >%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >clear all >fs =3D 1; >N =3D 8; > >tv =3D (0:N-1)/fs; >f =3D 0.125*fs; >x=3Dsin(2*pi*tv*f); >fv =3D(0:N-1)*fs/N; >X =3D fft(x); > >Nfft =3D 32; >fvzp=3D(0:Nfft-1)*fs/Nfft; >Xzp=3Dfft(x,Nfft); > > >clf >subplot(3,1,1) >stem(fvzp,abs(Xzp),'r'); >hold on >stem(fv,abs(X),'b'); >title('a) Spectrum Interpolation by Zero Padding') > >y =3D sin(2*pi*tv*0.14)+sin(2*pi*tv*0.2); >Y=3Dfft(y); >Yzp =3D fft(y,Nfft); >subplot(3,1,2) >stem(fvzp,abs(Yzp),'r'); >hold on >stem(fv,abs(Y),'b'); >stem([0.14,0.2,0.8,0.86],4*[1 1 1 1],'g') >title('b) Zero-padding does *not* resolve spikes') > >N =3D 32; >tv =3D (0:N-1)/fs; >z =3D sin(2*pi*tv*0.14)+sin(2*pi*tv*0.2); >fv =3D(0:N-1)*fs/N; > >subplot(3,1,3) >Z =3D fft(z); >Nfft =3D 128; >fvzp=3D(0:Nfft-1)*fs/Nfft; >Zzp=3Dfft(z,Nfft); > >stem(fvzp,abs(Zzp),'r'); >hold on >stem(fv,abs(Z),'b') >stem([0.14,0.2,0.8,0.86],16*[1 1 1 1],'g') >title('c) Sufficient data *does* resolve spikes') >
Reply by ●April 21, 20092009-04-21
On 21 Apr, 16:57, "fisico32" <marcoscipio...@gmail.com> wrote:> Hello Rune, > > thanks again for the clarification on zero padding and resolution. > So, semantics aside,Establishing a semantic basis is the key to communicate. In this case means you need to find out 1) The common terms used 2) What you want to say 3) Find a formulation that expresses what you want to say in a way that is in keeping with the established terminology.> zero padding does > 1) not change the form of the spectrum (good) > 2) not change the total bandwidth of signal (good) > 3) add new, more frequency values to the FFT. These values are > interpolated values that make the spectrum look better, more continuous. > > But, in my mind, resolution means getting more values, see deeper, more > precisely.Here the semantics you didn't care to learn all of a sudden splashes eggs all over your face: I have no idea what you mean.> And that seems to be what zero padding does. We can argue if > interpolated values are just estimations ( not as truthful as real data).Again, I have no idea what you mean. Read up on the basics and learn the established terminology.> However, to me it seems that zero padding actually increases resolution.No it doesn't. It interpolates the spectrum.> IF not, I am wrong again.Yes you are.> What causes then an increase in resolution?It depends on what you mean by 'resolution'.> Same data length but faster sampling (more data samples)?I gave a very detailed explanation + matlab example in my previous post, which you apparently did not care to read. If you want further help from me, re-read that post, run the example and learn the basic terminology. Then try and use that terminology to ask any follow-up questions. Rune
Reply by ●April 21, 20092009-04-21
sorry Rune, I will be more diligent and re-read your post. thanks again>On 21 Apr, 16:57, "fisico32" <marcoscipio...@gmail.com> wrote: >> Hello Rune, >> >> thanks again for the clarification on zero padding and resolution. >> So, semantics aside, > >Establishing a semantic basis is the key to communicate. >In this case means you need to find out > >1) The common terms used >2) What you want to say >3) Find a formulation that expresses what you want > to say in a way that is in keeping with the > established terminology. > >> zero padding does >> 1) not change the form of the spectrum (good) >> 2) not change the total bandwidth of signal (good) >> 3) add new, more frequency values to the FFT. These values are >> interpolated values that make the spectrum look better, morecontinuous.>> >> But, in my mind, resolution means getting more values, see deeper,more>> precisely. > >Here the semantics you didn't care to learn all of a sudden >splashes eggs all over your face: I have no idea what you mean. > >> And that seems to be what zero padding does. We can argue if >> interpolated values are just estimations ( not as truthful as realdata).> >Again, I have no idea what you mean. Read up on the basics >and learn the established terminology. > >> However, to me it seems that zero padding actually increasesresolution.> >No it doesn't. It interpolates the spectrum. > >> IF not, I am wrong again. > >Yes you are. > >> What causes then an increase in resolution? > >It depends on what you mean by 'resolution'. > >> Same data length but faster sampling (more data samples)? > >I gave a very detailed explanation + matlab example in my >previous post, which you apparently did not care to read. >If you want further help from me, re-read that post, run >the example and learn the basic terminology. > >Then try and use that terminology to ask any follow-up >questions. > >Rune >
Reply by ●April 21, 20092009-04-21
fisico32 wrote:> Hello Rune, > > thanks again for the clarification on zero padding and resolution. > So, semantics aside, zero padding does > 1) not change the form of the spectrum (good) > 2) not change the total bandwidth of signal (good) > 3) add new, more frequency values to the FFT. These values are > interpolated values that make the spectrum look better, more continuous. > > But, in my mind, resolution means getting more values, see deeper, more > precisely. And that seems to be what zero padding does. We can argue if > interpolated values are just estimations ( not as truthful as real data). > > However, to me it seems that zero padding actually increases resolution. > IF not, I am wrong again. What causes then an increase in resolution? > Same data length but faster sampling (more data samples)? > > thanks again > marco-- snip -- Understand the difference between resolution and precision. If you have a 13-inch long ruler that marks out 12 inches, and each inch has 128 lines (and you have a magnifying glass), then your resolution is less than 0.01", which is really good for a ruler. On the other hand, your _precision_ is over 8% off of true, so in many cases the resolution is useless. In the case of your FFT, zero padding adds resolution but can create artifacts (distantly akin to that 8% oversize ruler) that render the resolution pointless. Make sense? -- 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
Reply by ●April 21, 20092009-04-21
fisico32 schrieb:> But, in my mind, resolution means getting more values, see deeper, more > precisely. And that seems to be what zero padding does. We can argue if > interpolated values are just estimations ( not as truthful as real data).No it does not increase the resolution it just generates more measurement points. In measurement engineering (radar, sonar, tdr etc.) resolution is usually defined as the ability to distinguish between two signal sources in whatever your domain you are working in (time, frequency, spatial etc.). Therefore for your example if you have two signals in the time domain with a difference in the frequency which is below your resolution than you can not seperate them in the frequency domain no matter how many measurement points you are interpolating. You have two increase the measurement time or use a window that has a better resolution than the recangular one. I advise you to get hands on some basic textbooks about spectrum estimation or radar analysis if you can not follow me. Hope that helps. Sebastian
Reply by ●April 21, 20092009-04-21
fisico32 <marcoscipioni1@gmail.com> wrote:> thanks again for the clarification on zero padding and resolution. > So, semantics aside, zero padding does > 1) not change the form of the spectrum (good) > 2) not change the total bandwidth of signal (good) > 3) add new, more frequency values to the FFT. These values are > interpolated values that make the spectrum look better, more continuous.As with any interpolation method, yes, the data looks better and more continuous, but it is still the same data.> But, in my mind, resolution means getting more values, see deeper, more > precisely. And that seems to be what zero padding does. We can argue if > interpolated values are just estimations ( not as truthful as real data).Not any truth at all. There is no substitute for actually measuring something when you want to know its value.> However, to me it seems that zero padding actually increases resolution. > IF not, I am wrong again. What causes then an increase in resolution? > Same data length but faster sampling (more data samples)?Yes, for actual resolution you need more samples in the same amount of time. -- glen
Reply by ●April 21, 20092009-04-21
On 21 Apr, 21:42, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:> fisico32 <marcoscipio...@gmail.com> wrote:> > However, to me it seems that zero padding actually increases resolution. > > IF not, I am wrong again. What causes then an increase in resolution? > > Same data length but faster sampling (more data samples)? > > Yes, for actual resolution you need more samples in the same > amount of time.Hmmmm... I think you will find that the information contained in the extra data points is spent computing spectrum coefficients over a wider spectrum band. The quick'n dirty example is if you double the sampling frequency, you double the bandwidth. Unless you change the time over which you sample the signal, the width of the frequency bins remain unchanged. Rune






