From: suren on
On Feb 5, 9:03 pm, "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.
>
> 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.
>
> 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?
>
> In Summary, should there be a difference in the usual sine wave and zero
> padded sine wave with respect to frequency spectrum?
>
> Thanks
>
> Rahul

Rahul,
It seems that you misinterpreted the results. when you zero padded,
you zero padded at the original sampling rate itself. so now you have
2048 points at your original sampling rate and when you took the FFT
the bin at which you got the maximum power would now be twice the
original bin. since you did the FFT using 2N points instead of the
original N points,the actual freqeuency = new bin location*fs/(2N)
where fs is the original sampling rate and N is the original number of
points which in your case, is 1024. since the new bin location, is at
twice the original bin location, the actual frequency is still 1 Hz.

Hope this helps.

regards
suren
From: Ron N. on
On Feb 5, 8: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.
>
> 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.
>
> 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?
>
> In Summary, should there be a difference in the usual sine wave and zero
> padded sine wave with respect to frequency spectrum?

Yes. You have doubled the number of samples, and multiplied
your sine wave with a rectangular window formed by the zero
padding. Since the period of your sine wave is now half the
number of total samples, the frequency is doubled. And
multiplication by a rectangular window in the time domain will
convolve the frequency domain result with a (pair of) Sinc
function, which is the transform of the rectangular window.
The Sinc function has high frequency components across
the entire spectrum.


--
rhn A.T nicholson d.0.t C-o-M
http://www.nicholson.com/rhn/dsp.html
From: rsk on
>rsk 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.
>>
>> 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.
>>
>> 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?
>>
>> In Summary, should there be a difference in the usual sine wave and
zero
>> padded sine wave with respect to frequency spectrum?
>
>You tell us what you intended to do, but I can't analyze your result
>without knowing what you actually did. I can guess, though. Have you
>misinterpreted the frequencies associated with the bins in the second
>case? zero padding will make twice as many bins, so what was 1 Hz before
>becomes 0.5 Hz after padding.
>
>Jerry
>--
>Engineering is the art of making what you want from things you can get.
>�����������������������������������������������������������������������
>Thanks for your reply. I am getting little confused with the
interpretation. 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. Did you mean, even if I got 0.5 Hz as
the frequency, it is actually 1 HZ?. Also, why did the amplitude change?

Rahul
From: Rune Allnor on
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
From: Grant Griffin on
rsk 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.
>
> 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.
>
> 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?

Here's how I look at it. The frequency of the input sine is unchanged
by padding: it still took one second for the sine wave to go through one
cycle, even though you added 1 second worth of padding to it. However,
the number samples going into the FFT has doubled.

The calculation that converts a particular FFT bin number into Hz is
proportional to the bin number and sampling frequency, and inversely
proportional to the number of bins. I think the error in this case is
in your Hz calculation: the bin number the signal appeared in doubled
but so did the number of bins. So, those two doubling factors should
cancel and the Hz you calculate should be the same.

>
> In Summary, should there be a difference in the usual sine wave and zero
> padded sine wave with respect to frequency spectrum?


Yes, although zero padding doesn't change the signal _frequency_ it does
make the signal fundamentally different in some sense. Imagine if you
had repeated the signal to get 2 seconds worth of samples instead of
zero-padding it. Those would be two different signals. The repeated
signal would still be a true sine wave but the padded signal is not.

A true sine wave that falls exactly in the center of an FFT bin will
result in a single FFT line. However, if the sine wave is not pure in
some way, it will fall on multiple bins.

In technical terms, you can think of zero-padding as applying a
"rectangular window" to a repeating sine wave, and windowing causes
"spectral leakage", which in practical terms causes the FFT to show
non-zero components in bins near the center bin.

The usual goal of windowing is "to make the ends match up" (as a friend
of mine once said), but the rectangular window doesn't really do that.
So, better windows typically are used. And going back to the repeated
signal, notice that the (sine) ends match up, whereas they don't with
the zero-padded signal.

Iowegian has an A/D performance measurement tutorial at
http://www.iowegian.com/dsp/tutorial/adc that touches on many of these
issues.

Grant
--
_____________________________________________________________________

Grant R. Griffin
Publisher of dspGuru http://www.dspguru.com
Iowegian International Corporation http://www.iowegian.com
See http://www.iowegian.com/img/contact.gif for e-mail address