Sign in

username:

password:



Not a member?

Search compdsp



Search tips

comp.dsp by Keywords

Adaptive Filter | ADPCM | ADSP | ADSP-2181 | Aliasing | AMR | Anti-Aliasing | ARMA | Autocorrelation | AutoCovariance | Beamforming | Bessel | Blackfin | Butterworth | C6713 | CCS | Chebyshev | CIC Filter | Circular Convolution | Code Composer Studio | Comb Filter | Compression | Convolution | Cross Correlation | DCT | Decimation | Deconvolution | Demodulation | DM642 | DSP Boards | DSP/BIOS | DTMF | Echo Cancellation | Equalization | Equalizer | ETSI | EZLITE (Ez-kit Lite) | FFT | FFTW | FIR Filter | Fixed Point | FSK | G.711 | G.723 | G.729 | Gaussian Noise | Goertzel | GPIO | Hilbert Transform | IFFT | IIR Filter | Interpolation | Invariance | JTAG | Kalman | Laplace Transform | Levinson | LPC | McBSP | MIPS | Modulation | MPEG | Multirate | Notch Filter | Nyquist | OFDM | Oversampling | Pink Noise | Pitch | PLL | Polyphase | QAM | QDMA | Quantization | Quantizer | Radar | Random Noise | Reed Solomon | Remez | Resampling | RTDX | Sampling | Sharc | TI C6711 | Undersampling | Viterbi | Wavelets | White Noise | Wiener Filter | Windowing | XDS510PP | Z Transform


Discussion Groups

Free Online Books

See Also

Embedded SystemsFPGAElectronics

Discussion Groups | Comp.DSP | Should the normal SINE and Zero padded SINE curves be the same for fft output?


There are 35 messages in this thread.

You are currently looking at messages 0 to 10.


Should the normal SINE and Zero padded SINE curves be the same for fft output? - rsk - 2010-02-05 11:03:00

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


______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - Jerry Avins - 2010-02-05 11:23:00



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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - Rune Allnor - 2010-02-05 13:21:00

On 5 Feb, 17:03, "rsk" <kalera...@yahoo.com> wrote:

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

Of course. The two signals are diffrent, so their spectra
should be different. This is a trivial consequence of the
DFT being a linear operation.

Rune
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - foxcob - 2010-02-05 13:38:00

>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
>

I believe what you are seeing is the Gibbs phenomenon.  When you pad the
input with zeros, you are creating an edge or transition where the sine
wave stops.  This transition contains harmonics of the 1Hz sine wave you
sampled.

Jacob

______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - robert bristow-johnson - 2010-02-05 13:56:00

On Feb 5, 1:38=A0pm, "foxcob" <jacob.the...@gmail.com> wrote:
>
> >This might have been discussed multiple times. However, I am new comer t=
o
> >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 =3D 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?
>
>
> I believe what you are seeing is the Gibbs phenomenon. =A0When you pad th=
e
> input with zeros, you are creating an edge or transition where the sine
> wave stops. =A0This transition contains harmonics of the 1Hz sine wave yo=
u
> sampled.

even if there is no zero-padding, there is Gibbs phenomena when the
number of cycles of the sinusoid in the FFT buffer is not an integer
(because of the discontinuity where it wraps around from x[N-1] to
x[0])

if the number of cycles in the FFT buffer is a nice integer (let's say
that integer is M) you will see a nice clean spike at X[M] and at X[N-
M] (i mean that X[0] is the DC component, in case you're using MATLAB)
with zeros or very low-level noise in the other bins.

r b-j
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - dbd - 2010-02-05 19:34:00

On Feb 5, 8:03=A0am, "rsk" <kalera...@yahoo.com> wrote:
> ...
> In Summary, should there be a difference in the usual sine wave and zero
> padded sine wave with respect to frequency spectrum?
> ...

When the fft results are plotted on the same frequency scale from 0 to
Fs, the results should be the same for any frequency for which a
sample is generated. Zero sampling to N timed the original data length
will generate each of the unextended frequency samples and N-1
intermediate (in frequency) samples.

If you have access to Matlab, you can plot examples from the following
snippet:

% 4 Hz Sine, 32 point fft, 64 point w/ zero fill
% Sample Freq =3D 32 Hz
hz4 =3D cos(4*2*pi*(0:31)/32);
hz4zeros =3D zeros(1,64); hz4zeros(1:32) =3D hz4;
hz4x128 =3D zeros(1,128); hz4x128(1:32) =3D hz4;
hz4x512 =3D zeros(1,512); hz4x512(1:32) =3D hz4;

figure % First
plot( ...
    (0:31),hz4,'ro',      (0:31),hz4,'r-', ...
    (0:63),hz4zeros,'kx', (0:63),hz4zeros,'k:')
title('Time Domain Plot')
xlabel('Sample: Red-o-32 samples   Black-x-64 samples')
axis([-2 66 -1.2 1.2])
grid on

figure % Second
plot( ...
    linspace(0,1-(1/128),128),real(fft(hz4x128)),'b+', ...
    linspace(0,1-(1/32),32),real(fft(hz4)),'ro', ...
    linspace(0,1-(1/64),64),real(fft(hz4zeros)),'kx', ...
    linspace(0,1-(1/128),128),real(fft(hz4x128)),'b-', ...
    linspace(0,1-(1/32),32),real(fft(hz4)),'r-', ...
    linspace(0,1-(1/64),64),real(fft(hz4zeros)),'k:')
title('Frequency Domain Plot')
ylabel('FFT Response')
xlabel('Fraction of Sample Freq.  Zero-fill:Red:none Blk:x2 Blu:x4')
axis([-0.02 0.52 -18 18]); grid on

figure % Third
plot( ...
    linspace(0,1-(1/512),512),real(fft(hz4x512)),'g*', ...
    linspace(0,1-(1/512),512),real(fft(hz4x512)),'g-', ...
    linspace(0,1-(1/128),128),real(fft(hz4x128)),'bx', ...
    linspace(0,1-(1/32),32),real(fft(hz4)),'ro', ...
    linspace(0,1-(1/64),64),real(fft(hz4zeros)),'k+', ...
    linspace(0,1-(1/64),64),real(fft(hz4zeros)),'k-', ...
    linspace(0,1-(1/32),32),real(fft(hz4)),'r-', ...
    linspace(0,1-(1/128),128),real(fft(hz4x128)),'b-')
title('Frequency Domain Plot, Expanded about peak')
xlabel('Zero-fill Red:none Blk:x2 Blu:x4 Grn:x16')
ylabel('FFT Response')
axis([0.09 0.16 -18 18]); grid on

Dale B. Dalrymple
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - suren - 2010-02-06 00:42:00

On Feb 5, 9:03=A0pm, "rsk" <kalera...@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 =3D 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 =3D 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
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - Ron N. - 2010-02-06 01:36:00

On Feb 5, 8:03=A0am, "rsk" <kalera...@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 =3D 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
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - rsk - 2010-02-06 05:16:00

>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
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

Re: Should the normal SINE and Zero padded SINE curves be the same for fft output? - Rune Allnor - 2010-02-06 05:22:00

On 6 Feb, 11:16, "rsk" <kalera...@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
______________________________
DSPRelated.com's 50,000th member announced! Details Here.

| 1 | 2 | 3 | 4 | next