DSPRelated.com
Forums

zero padding

Started by shamma February 25, 2010
hi 
suppose i have data   x=[1 2]

i want to ask which is correct way of padding zeros 

1) [ 0 1 2 0]

or 

2)[ 1 2 0 0 ] which is effectively fft(x,4) 


Thanks 
 
On 25 Feb, 10:10, "shamma" <shammashah...@yahoo.com> wrote:
> hi > suppose i have data =A0 x=3D[1 2] > > i want to ask which is correct way of padding zeros > > 1) [ 0 1 2 0] > > or > > 2)[ 1 2 0 0 ] which is effectively fft(x,4)
You can do it either way. The key is that you append zeros before and / or after the sequence x, not inside. Rune
>On 25 Feb, 10:10, "shamma" <shammashah...@yahoo.com> wrote: >> hi >> suppose i have data =A0 x=3D[1 2] >> >> i want to ask which is correct way of padding zeros >> >> 1) [ 0 1 2 0] >> >> or >> >> 2)[ 1 2 0 0 ] which is effectively fft(x,4) > >You can do it either way. The key is that you append zeros >before and / or after the sequence x, not inside. > >Rune >
what if it is like this x=[ 1 0 0 2] what effect would it have ?
>On 25 Feb, 10:10, "shamma" <shammashah...@yahoo.com> wrote: >> hi >> suppose i have data =A0 x=3D[1 2] >> >> i want to ask which is correct way of padding zeros >> >> 1) [ 0 1 2 0] >> >> or >> >> 2)[ 1 2 0 0 ] which is effectively fft(x,4)
1) is better
On Feb 25, 2:10=A0pm, "shamma" <shammashah...@yahoo.com> wrote:
> hi > suppose i have data =A0 x=3D[1 2] > > i want to ask which is correct way of padding zeros > > 1) [ 0 1 2 0] > > or > > 2)[ 1 2 0 0 ] which is effectively fft(x,4) > > Thanks
I think both are equivalent. If you stack copies of [1 2 0 0] or [0 1 2 0] to form a periodic signal, both look the same, except for a sample delay.The amplitude spectra of both should be same. Did you check that ? regards suren
Avier wrote:
>> On 25 Feb, 10:10, "shamma" <shammashah...@yahoo.com> wrote: >>> hi >>> suppose i have data =A0 x=3D[1 2] >>> >>> i want to ask which is correct way of padding zeros >>> >>> 1) [ 0 1 2 0] >>> >>> or >>> >>> 2)[ 1 2 0 0 ] which is effectively fft(x,4) > > > > 1) is better
Why? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Feb 25, 1:52=A0am, suren <suren.r...@gmail.com> wrote:
> On Feb 25, 2:10=A0pm, "shamma" <shammashah...@yahoo.com> wrote: > > > hi > > suppose i have data =A0 x=3D[1 2] > > > i want to ask which is correct way of padding zeros > > > 1) [ 0 1 2 0] > > > or > > > 2)[ 1 2 0 0 ] which is effectively fft(x,4) > > > Thanks > ...
.> I think both are equivalent. If you stack copies of [1 2 0 0] or [0 1 .> 2 0] to form a periodic signal, both look the same, except for a .> sample delay.The amplitude spectra of both should be same. Did you .> check that ? .> .> regards .> suren The delay makes the phases different. The OP hasn't told us enough to know if amplitude only is 'correct' enough. Dale B. Dalrymple
shamma wrote:
>> On 25 Feb, 10:10, "shamma" <shammashah...@yahoo.com> wrote: >>> hi >>> suppose i have data =A0 x=3D[1 2] >>> >>> i want to ask which is correct way of padding zeros >>> >>> 1) [ 0 1 2 0] >>> >>> or >>> >>> 2)[ 1 2 0 0 ] which is effectively fft(x,4) >> You can do it either way. The key is that you append zeros >> before and / or after the sequence x, not inside. >> >> Rune >> > > > what if it is like this > x=[ 1 0 0 2] > what effect would it have ?
_If_ you are zero padding to take an FFT then it has the effect of reversing the sequence. The FFT mathematically treats the data as one cycle of periodic data, so [1 2 0 0], [0 1 2 0], [0 0 1 2], and [2 0 0 1] will all give the same amplitude response with different phase responses. If phase isn't important then zero pad by whatever method is convenient. If phase _is_ important then (a) do the little uphill climb to understand the relation between delay and phase, (b) do the _big_ uphill climb to relate that to your problem at hand, and (c) figure out the appropriate zero padding on your own. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
>shamma wrote: >>> On 25 Feb, 10:10, "shamma" <shammashah...@yahoo.com> wrote: >>>> hi >>>> suppose i have data =A0 x=3D[1 2] >>>> >>>> i want to ask which is correct way of padding zeros >>>> >>>> 1) [ 0 1 2 0] >>>> >>>> or >>>> >>>> 2)[ 1 2 0 0 ] which is effectively fft(x,4) >>> You can do it either way. The key is that you append zeros >>> before and / or after the sequence x, not inside. >>> >>> Rune >>> >> >> >> what if it is like this >> x=[ 1 0 0 2] >> what effect would it have ? > >_If_ you are zero padding to take an FFT then it has the effect of >reversing the sequence. The FFT mathematically treats the data as one >cycle of periodic data, so [1 2 0 0], [0 1 2 0], [0 0 1 2], and [2 0 0 >1] will all give the same amplitude response with different phase
responses.
> >If phase isn't important then zero pad by whatever method is convenient. > If phase _is_ important then (a) do the little uphill climb to >understand the relation between delay and phase, (b) do the _big_ uphill >climb to relate that to your problem at hand, and (c) figure out the >appropriate zero padding on your own. > >-- >Tim Wescott >Control system and signal processing consulting >www.wescottdesign.com
i think the questioned is well answered ,,,,,,why i said that 1st method was better was because of its ease in implementation in case of matlab ,,,for other languagesthe two methods may be quite same
On Feb 26, 2:02&#4294967295;pm, "Avier" <shahanwark...@hotmail.com> wrote:
> >shamma wrote: > >>> On 25 Feb, 10:10, "shamma" <shammashah...@yahoo.com> wrote: > >>>> hi > >>>> suppose i have data =A0 x=3D[1 2] > > >>>> i want to ask which is correct way of padding zeros > > >>>> 1) [ 0 1 2 0] > > >>>> or > > >>>> 2)[ 1 2 0 0 ] which is effectively fft(x,4) > >>> You can do it either way. The key is that you append zeros > >>> before and / or after the sequence x, not inside. > > >>> Rune > > >> what if it is like this > >> x=[ 1 0 0 2] > >> what effect would it have ? > > >_If_ you are zero padding to take an FFT then it has the effect of > >reversing the sequence. &#4294967295;The FFT mathematically treats the data as one > >cycle of periodic data, so [1 2 0 0], [0 1 2 0], [0 0 1 2], and [2 0 0 > >1] will all give the same amplitude response with different phase > responses. > > >If phase isn't important then zero pad by whatever method is convenient. > > &#4294967295;If phase _is_ important then (a) do the little uphill climb to > >understand the relation between delay and phase, (b) do the _big_ uphill > >climb to relate that to your problem at hand, and (c) figure out the > >appropriate zero padding on your own. > > >-- > >Tim Wescott > >Control system and signal processing consulting > >www.wescottdesign.com > > i think the questioned is well answered ,,,,,,why i said that 1st method > was better was because of its ease in implementation &#4294967295;in case of matlab > ,,,for other languagesthe two methods may be quite same- Hide quoted text - > > - Show quoted text -
Easier in Matlab how? Dirk