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:
why fft(ifft(y)) ~= y ?

Subject: why fft(ifft(y)) ~= y ?

From: Ray Lee

Date: 16 May, 2014 14:41:13

Message: 1 of 3

Hey gus, I met a very strange situation that the fft(ifft(y)) is not the same as y. Here is my code.

figure;
n = 2e3;
t = 1:n;
m = n/2+1;
f = linspace(0,1,m);
x = rand(1,n) - 0.5;
y = fft(x);
subplot(2,2,1); plot(t,x,'k');
axis tight; xlabel('t/s'); title('original signal x');
subplot(2,2,2); plot(f,abs(y(1:m)),'k');
axis tight; xlabel('f/hz'); title('original spectrum');
y1 = y ./ abs(y);
k = n/10;
w = sin(linspace(0,pi/2,k));
y1(1:k) = y1(1:k) .* w;
y1(m:-1:m-k+1) = y1(m:-1:m-k+1) .* w;
y1(n-m+3:n) = y1(m-1:-1:2);
x1 = real(ifft(y1));
y2 = fft(x1);
x2 = real(ifft(y2));
subplot(2,2,3); plot(t,x1,'k',t,x2-x1,'r');
axis tight; xlabel('t/s'); title('whitened signal x1(black) and x2-x1(red)');
subplot(2,2,4); plot(f,abs(y1(1:m)),'k',f,abs(y2(1:m)),'r');
axis tight; xlabel('f/hz'); title('whitened spectrum y1(black) and y2(red)');

As you can see in subplot 3, x1 and x2 are the same (the difference is zero; see red line), but their spectrum in subplot 4 (black and red) is different.

Subject: why fft(ifft(y)) ~= y ?

From: Ray Lee

Date: 16 May, 2014 15:31:09

Message: 2 of 3

if you don't want run the code, here is the output figure.

http://i.stack.imgur.com/5kYVf.jpg

Subject: why fft(ifft(y)) ~= y ?

From: Ray Lee

Date: 16 May, 2014 15:35:13

Message: 3 of 3

If you don't want to run the code, here is the output figure [ i.stack.imgur.com/5kYVf.jpg ]

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