From: RSK on
Are these two signals same with respect to frequency spectrum? one is zero padded and one has two cycles. If zero padding would just add interpolated points in the original spectrum, then would the spectrum for both of these same?

Signal 1 (zero padded after first cycle)

Time Amplitude
0 0
1 1
2 0
3 0
4 0
5 0

Signal 2 (two cycles)


Time Amplitude
0 0
1 1
2 0
3 0
4 1
5 0
From: Wayne King on
"RSK " <kalerahul(a)yahoo.com> wrote in message <hv9o1n$nf0$1(a)fred.mathworks.com>...
> Are these two signals same with respect to frequency spectrum? one is zero padded and one has two cycles. If zero padding would just add interpolated points in the original spectrum, then would the spectrum for both of these same?
>
> Signal 1 (zero padded after first cycle)
>
> Time Amplitude
> 0 0
> 1 1
> 2 0
> 3 0
> 4 0
> 5 0
>
> Signal 2 (two cycles)
>
>
> Time Amplitude
> 0 0
> 1 1
> 2 0
> 3 0
> 4 1
> 5 0

Hi, I don't see how the second signal is two cycles of the first signal. Maybe I'm not identifying your signal correctly since you have it in matrix form, but it appears to me you are calling the signal (Signal 1):

x= [0 0
1 1
2 0
3 0
4 0
5 0];
x = reshape(x,12,1);

% 0 1 2 3 4 5 0 1 0 0 0 0

What is the signal before the zero padding?
[0 1 2 3 4 5 0 1] ?

In which case, if the second signal were two cycles of that, it would be

x = [0 1 2 3 4 5 0 1];
x1 = repmat(x,1,2);

Note the following:

% 6 cycles of a 1/10 Hz wave
x = cos(2*pi*(1/10)*(0:59)');
% zero pad out an additional 4 cycles
x = [x; zeros(40,1)];
% 10 cycles of 1/10 Hz wave
x1 = cos(2*pi*(1/10)*(0:99)');
% plot their magnitude spectrums
plot(abs(fft(x)),'k'); hold on;
plot(abs(fft(x1)),'b');
legend('zero padded','not padded','location','north');

Wayne
From: RSK on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <hva8qf$lrf$1(a)fred.mathworks.com>...
> "RSK " <kalerahul(a)yahoo.com> wrote in message <hv9o1n$nf0$1(a)fred.mathworks.com>...
> > Are these two signals same with respect to frequency spectrum? one is zero padded and one has two cycles. If zero padding would just add interpolated points in the original spectrum, then would the spectrum for both of these same?
> >
> > Signal 1 (zero padded after first cycle)
> >
> > Time Amplitude
> > 0 0
> > 1 1
> > 2 0
> > 3 0
> > 4 0
> > 5 0
> >
> > Signal 2 (two cycles)
> >
> >
> > Time Amplitude
> > 0 0
> > 1 1
> > 2 0
> > 3 0
> > 4 1
> > 5 0
>
> Hi, I don't see how the second signal is two cycles of the first signal. Maybe I'm not identifying your signal correctly since you have it in matrix form, but it appears to me you are calling the signal (Signal 1):
>
> x= [0 0
> 1 1
> 2 0
> 3 0
> 4 0
> 5 0];
> x = reshape(x,12,1);
>
> % 0 1 2 3 4 5 0 1 0 0 0 0
>
> What is the signal before the zero padding?
> [0 1 2 3 4 5 0 1] ?
>
> In which case, if the second signal were two cycles of that, it would be
>
> x = [0 1 2 3 4 5 0 1];
> x1 = repmat(x,1,2);
>
> Note the following:
>
> % 6 cycles of a 1/10 Hz wave
> x = cos(2*pi*(1/10)*(0:59)');
> % zero pad out an additional 4 cycles
> x = [x; zeros(40,1)];
> % 10 cycles of 1/10 Hz wave
> x1 = cos(2*pi*(1/10)*(0:99)');
> % plot their magnitude spectrums
> plot(abs(fft(x)),'k'); hold on;
> plot(abs(fft(x1)),'b');
> legend('zero padded','not padded','location','north');
>
> Wayne

Wayne,

The first column is time and second is amplitude. The two signals have triangle with peak amplitude 1.
From: Wayne King on
"RSK " <kalerahul(a)yahoo.com> wrote in message <hvab18$77n$1(a)fred.mathworks.com>...
> "Wayne King" <wmkingty(a)gmail.com> wrote in message <hva8qf$lrf$1(a)fred.mathworks.com>...
> > "RSK " <kalerahul(a)yahoo.com> wrote in message <hv9o1n$nf0$1(a)fred.mathworks.com>...
> > > Are these two signals same with respect to frequency spectrum? one is zero padded and one has two cycles. If zero padding would just add interpolated points in the original spectrum, then would the spectrum for both of these same?
> > >
> > > Signal 1 (zero padded after first cycle)
> > >
> > > Time Amplitude
> > > 0 0
> > > 1 1
> > > 2 0
> > > 3 0
> > > 4 0
> > > 5 0
> > >
> > > Signal 2 (two cycles)
> > >
> > >
> > > Time Amplitude
> > > 0 0
> > > 1 1
> > > 2 0
> > > 3 0
> > > 4 1
> > > 5 0
> >
> > Hi, I don't see how the second signal is two cycles of the first signal. Maybe I'm not identifying your signal correctly since you have it in matrix form, but it appears to me you are calling the signal (Signal 1):
> >
> > x= [0 0
> > 1 1
> > 2 0
> > 3 0
> > 4 0
> > 5 0];
> > x = reshape(x,12,1);
> >
> > % 0 1 2 3 4 5 0 1 0 0 0 0
> >
> > What is the signal before the zero padding?
> > [0 1 2 3 4 5 0 1] ?
> >
> > In which case, if the second signal were two cycles of that, it would be
> >
> > x = [0 1 2 3 4 5 0 1];
> > x1 = repmat(x,1,2);
> >
> > Note the following:
> >
> > % 6 cycles of a 1/10 Hz wave
> > x = cos(2*pi*(1/10)*(0:59)');
> > % zero pad out an additional 4 cycles
> > x = [x; zeros(40,1)];
> > % 10 cycles of 1/10 Hz wave
> > x1 = cos(2*pi*(1/10)*(0:99)');
> > % plot their magnitude spectrums
> > plot(abs(fft(x)),'k'); hold on;
> > plot(abs(fft(x1)),'b');
> > legend('zero padded','not padded','location','north');
> >
> > Wayne
>
> Wayne,
>
> The first column is time and second is amplitude. The two signals have triangle with peak amplitude 1.

Hi, Sorry, my fault. I somehow read right past the amplitude-time labels, I see now that was clear. I think maybe your example isn't the best comparison since you only have one period of your waveform [0 1 0]. A spectral estimate of one period of any waveform isn't going to be very good. You need a few periods. So let's construct a few periods of your triangle waveform.

% ten periods of your waveform
x = [0 1 0];
x1 = repmat(x,1,10);
% zero pad it out to a length of 20 periods
x1 =[x1 zeros(1,30)];

% 20 periods no zero padding
x2 = repmat(x,1,20);
plot(abs(fftshift(fft(x1))),'k'); hold on;
plot(abs(fftshift(fft(x2))),'b');
legend('zero padded','not padded','location','north');

Note that the spectra are not the same, but if you are using the spectrum as a way of identifying oscillations in a signal, then both agree in their identification of the peaks.

Wayne
From: RSK on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <hvacpi$qkj$1(a)fred.mathworks.com>...
> "RSK " <kalerahul(a)yahoo.com> wrote in message <hvab18$77n$1(a)fred.mathworks.com>...
> > "Wayne King" <wmkingty(a)gmail.com> wrote in message <hva8qf$lrf$1(a)fred.mathworks.com>...
> > > "RSK " <kalerahul(a)yahoo.com> wrote in message <hv9o1n$nf0$1(a)fred.mathworks.com>...
> > > > Are these two signals same with respect to frequency spectrum? one is zero padded and one has two cycles. If zero padding would just add interpolated points in the original spectrum, then would the spectrum for both of these same?
> > > >
> > > > Signal 1 (zero padded after first cycle)
> > > >
> > > > Time Amplitude
> > > > 0 0
> > > > 1 1
> > > > 2 0
> > > > 3 0
> > > > 4 0
> > > > 5 0
> > > >
> > > > Signal 2 (two cycles)
> > > >
> > > >
> > > > Time Amplitude
> > > > 0 0
> > > > 1 1
> > > > 2 0
> > > > 3 0
> > > > 4 1
> > > > 5 0
> > >
> > > Hi, I don't see how the second signal is two cycles of the first signal. Maybe I'm not identifying your signal correctly since you have it in matrix form, but it appears to me you are calling the signal (Signal 1):
> > >
> > > x= [0 0
> > > 1 1
> > > 2 0
> > > 3 0
> > > 4 0
> > > 5 0];
> > > x = reshape(x,12,1);
> > >
> > > % 0 1 2 3 4 5 0 1 0 0 0 0
> > >
> > > What is the signal before the zero padding?
> > > [0 1 2 3 4 5 0 1] ?
> > >
> > > In which case, if the second signal were two cycles of that, it would be
> > >
> > > x = [0 1 2 3 4 5 0 1];
> > > x1 = repmat(x,1,2);
> > >
> > > Note the following:
> > >
> > > % 6 cycles of a 1/10 Hz wave
> > > x = cos(2*pi*(1/10)*(0:59)');
> > > % zero pad out an additional 4 cycles
> > > x = [x; zeros(40,1)];
> > > % 10 cycles of 1/10 Hz wave
> > > x1 = cos(2*pi*(1/10)*(0:99)');
> > > % plot their magnitude spectrums
> > > plot(abs(fft(x)),'k'); hold on;
> > > plot(abs(fft(x1)),'b');
> > > legend('zero padded','not padded','location','north');
> > >
> > > Wayne
> >
> > Wayne,
> >
> > The first column is time and second is amplitude. The two signals have triangle with peak amplitude 1.
>
> Hi, Sorry, my fault. I somehow read right past the amplitude-time labels, I see now that was clear. I think maybe your example isn't the best comparison since you only have one period of your waveform [0 1 0]. A spectral estimate of one period of any waveform isn't going to be very good. You need a few periods. So let's construct a few periods of your triangle waveform.
>
> % ten periods of your waveform
> x = [0 1 0];
> x1 = repmat(x,1,10);
> % zero pad it out to a length of 20 periods
> x1 =[x1 zeros(1,30)];
>
> % 20 periods no zero padding
> x2 = repmat(x,1,20);
> plot(abs(fftshift(fft(x1))),'k'); hold on;
> plot(abs(fftshift(fft(x2))),'b');
> legend('zero padded','not padded','location','north');
>
> Note that the spectra are not the same, but if you are using the spectrum as a way of identifying oscillations in a signal, then both agree in their identification of the peaks.
>
> Wayne


Wayne,

Thank you much for working it out for me. Actually, I am trying to understand why people say that zero padding just interpolates and does not add any other information. In this example, the blue curve is quite different than the green. This is exactly what I want to know. If the two signals are the forces measured at a point on the structure and if I need to find response due to these forces, using either of the curves as an input force would give different output compared to the other.
Conside a case in which I measure only 10 periods of the force waveform and zeropad it wth another 20 periods as you have done. By doing this, I am going to create spurious forces at the other frequencies which would not apprear if I had acquired 30 periods of waveform.
For me then, the zero padding proves detrimental as it is producing peaks at other frequencies and it will eventually generate structural response at those frequencies which would be a 'false' response.

Not sure if I am making myself clear.

Any comments?

In summary, I want to know if any 'physical' waveform(like force, displacement etc) can be zero padded to any lenght without affecting the outcome. This is generally encountered when we acquire data less than the next power of two( I mean, say 1500 samples instead of 2048)

Thanks

RSK
 |  Next  |  Last
Pages: 1 2 3
Prev: perpendiculars
Next: Output for svmclassify