Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
FFT, zero padding and IFFT

Subject: FFT, zero padding and IFFT

From: samuele

Date: 16 Jul, 2012 07:09:08

Message: 1 of 5

Hello Everybody,
I have a question corning the zero padding and the FFT. I learned a couple of years ago that if I zeropad a vector in frequency domain and I come back in time domain, the vector in time domain is interpolated (i.e between the original samples I added samples that are "average" between two samples).

My question is the following, why if I run this example (FFT, zero padding, IFFT) I always obtain a complex signal instead of obtaining the original signal interpolated??

v = [1 2 3 4];
fv = fft(v);
fvzp = [fv 0 0 0 0];
vzp = ifft(fvzp)
vzp =

  Columns 1 through 4

   0.5000 1.2500 - 0.2500i 1.0000 1.2500 - 0.4571i

  Columns 5 through 8

   1.5000 1.2500 - 0.2500i 2.0000 1.2500 + 0.9571i

Thanks,

Samuele

Subject: FFT, zero padding and IFFT

From: Idin Motedayen-Aval

Date: 16 Jul, 2012 15:27:32

Message: 2 of 5

Hi Samuele,
"The discrete Fourier transform of a real-valued signal is conjugate
symmetric."
When you zero-pad your FFT, it's no longer conjugate symmetric, so its
IFFT cannot be a real-value signal.

And this is in fact interpolating your signal. Just for kicks, try this:
v = [0 1 2 3 4];
fv = fft(v);
fvzp = [(fv) zeros(1,200)];
vzp = ifft(fvzp);
plot(abs(vzp))

(this is an "interpolate" version of your signal, and scaled to keep its
total energy the same).

On 7/16/2012 3:09 AM, Samuele wrote:
> Hello Everybody,
> I have a question corning the zero padding and the FFT. I learned a
> couple of years ago that if I zeropad a vector in frequency domain and I
> come back in time domain, the vector in time domain is interpolated (i.e
> between the original samples I added samples that are "average" between
> two samples).
>
> My question is the following, why if I run this example (FFT, zero
> padding, IFFT) I always obtain a complex signal instead of obtaining the
> original signal interpolated??
> v = [1 2 3 4];
> fv = fft(v);
> fvzp = [fv 0 0 0 0]; vzp = ifft(fvzp)
> vzp =
>
> Columns 1 through 4
>
> 0.5000 1.2500 - 0.2500i 1.0000 1.2500 -
> 0.4571i
>
> Columns 5 through 8
>
> 1.5000 1.2500 - 0.2500i 2.0000 1.2500 +
> 0.9571i
>
> Thanks,
>
> Samuele


--
Idin Motedayen-Aval
The MathWorks, Inc.
zq=[4 2 5 -15 -1 -3 24 -57 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2];
char(filter(1,[1,-1],[105 zq])), clear zq

Subject: FFT, zero padding and IFFT

From: Greg Heath

Date: 17 Jul, 2012 02:19:08

Message: 3 of 5

Idin Motedayen-Aval <run.signature@MATLAB.for.email> wrote in message <ju1bt4$mg0$1@newscl01ah.mathworks.com>...
> Hi Samuele,
> "The discrete Fourier transform of a real-valued signal is conjugate
> symmetric."
> When you zero-pad your FFT, it's no longer conjugate symmetric, so its
> IFFT cannot be a real-value signal.
>
> And this is in fact interpolating your signal. Just for kicks, try this:
> v = [0 1 2 3 4];

Note:

1. length(v) = 5 is odd
2. The 100% discontinuity in the periodic extension of v. This can cause Gibbs Phenomena
effects.

> fv = fft(v);
> fvzp = [(fv) zeros(1,200)];

No! This is not conjugate symmetric.

Hope this helps.

Greg

Subject: FFT, zero padding and IFFT

From: Bruno Luong

Date: 17 Jul, 2012 03:42:20

Message: 4 of 5

"Samuele " <samuele_82@hotmail.com> wrote in message <ju0emk$3j0$1@newscl01ah.mathworks.com>...
> Hello Everybody,
> I have a question corning the zero padding and the FFT. I learned a couple of years ago that if I zeropad a vector in frequency domain and I come back in time domain, the vector in time domain is interpolated (i.e between the original samples I added samples that are "average" between two samples).

You should pad in the high frequencies, which are located in the middle of the output of the fft, not the tail of it.

% Example data
n = 100;
x=linspace(-3,3,n);
y=1./((x-0.5).^2+1);
z = fft(y);

% Pad the high frequency
padsize = 28/2;
if mod(length(z),2) % odd
    zp = ifftshift([zeros(1,padsize) fftshift(z) zeros(1,padsize)]);
else % even
    zp = fftshift(z);
    zp(1) = zp(1)/2;
    zp(end+1) = zp(1);
    zp = ifftshift([zeros(1,padsize) zp zeros(1,padsize-1)]);
end

% Resampling, renormalization
xp = linspace(x(1),x(end),length(zp));
yp = ifft(zp)/length(z)*length(zp);

% Check
figure()
plot(xp,yp,'b',x, y,'r')

% Bruno

Subject: FFT, zero padding and IFFT

From: samuele

Date: 17 Jul, 2012 11:09:16

Message: 5 of 5

Thanks guys for the help, now it's clear !! :) :)

Samuele


"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ju2mus$5im$1@newscl01ah.mathworks.com>...
> "Samuele " <samuele_82@hotmail.com> wrote in message <ju0emk$3j0$1@newscl01ah.mathworks.com>...
> > Hello Everybody,
> > I have a question corning the zero padding and the FFT. I learned a couple of years ago that if I zeropad a vector in frequency domain and I come back in time domain, the vector in time domain is interpolated (i.e between the original samples I added samples that are "average" between two samples).
>
> You should pad in the high frequencies, which are located in the middle of the output of the fft, not the tail of it.
>
> % Example data
> n = 100;
> x=linspace(-3,3,n);
> y=1./((x-0.5).^2+1);
> z = fft(y);
>
> % Pad the high frequency
> padsize = 28/2;
> if mod(length(z),2) % odd
> zp = ifftshift([zeros(1,padsize) fftshift(z) zeros(1,padsize)]);
> else % even
> zp = fftshift(z);
> zp(1) = zp(1)/2;
> zp(end+1) = zp(1);
> zp = ifftshift([zeros(1,padsize) zp zeros(1,padsize-1)]);
> end
>
> % Resampling, renormalization
> xp = linspace(x(1),x(end),length(zp));
> yp = ifft(zp)/length(z)*length(zp);
>
> % Check
> figure()
> plot(xp,yp,'b',x, y,'r')
>
> % Bruno

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us