Borrar filtros
Borrar filtros

ifft after one fft

1 visualización (últimos 30 días)
21did21
21did21 el 24 de Abr. de 2013
Hi all,
i am trying to perform an "ifft" after a "fft" but i have a problem when the number of points for my "fft" has not the same length than my function length.
bellow, you have my test code to try to understand :
%fonction
t=linspace(0,100,1000);
y=0.3*sin(2*pi*10*t)+0.6*sin(2*pi*20*t)+0.9*sin(2*pi*30*t);
%first case : number of pts is same
spectreFFT1=fft(y);
y1=ifft(spectreFFT1);
figure (1);plot(t,y,'ob',t,y1,'r');
%second case : number of pts is different
pts = 2^nextpow2(length(t));
spectreFFT2=fft(y,pts);
y2=ifft(spectreFFT2,length(t));
figure (2);plot(t,y,'b',t,y2,'r');
thanks for your help !!

Respuesta aceptada

Wayne King
Wayne King el 24 de Abr. de 2013
Editada: Wayne King el 24 de Abr. de 2013
The DFT and inverse DFT are mappings from a N-dimensional complex vector space to an N-dimensional complex vector space.
When you change N as you do by padding, then they are different, so you cannot expect the vectors to be the same.
What you can do is this:
spectreFFT2 = fft(y,pts);
y2 = ifft(spectreFFT2);
y2 = y2(1:length(y));
figure (2);plot(t,y,'b',t,y2,'r');
Since padding is just appending zeros, you simply remove the zeros at the end.
  1 comentario
21did21
21did21 el 24 de Abr. de 2013
thanks for your help, nice !!!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by