- You do not need to divide by No after either the forward or backward transform. Normalisations are applied by fft and ifft so that the inverse is correct. Removing these divisions removes the drastic change of scale (so you can omit the calls to ylim ).
- You must not call abs before taking the inverse. This merges the real and imaginary parts of Z_cos, losing information.
- You must not call abs after taking the inverse. This inverts the negative parts of the output curve, giving little cusps at the troughs of the wave.
- You must call ifftshift before ifft to correctly reverse the effect of fftshift . That is, you need x_2_recovered=ifft(ifftshift(Z_cos)).
- You must compare the result of the transform and its inverse with the correct original time series, so you need to plot z and not x_2 as the original if you want to see that that the fft has been inverted as expected.
Using ifft to Recover Cosine from Two Delta Impulses
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Pyro
el 6 de Mzo. de 2015
EDIT: *code removed*
The recovered cosine is different from the original one. The reocvered one is the absolute value of the original one. Where am I going wrong?
0 comentarios
Respuesta aceptada
David Young
el 6 de Mzo. de 2015
Editada: David Young
el 6 de Mzo. de 2015
There are a number of reasons for the differences:
After making these changes, I got identical-looking plots. You should find that the maximum absolute difference between z and x_2_recovered is very small, though they will not be identical due to arithmetic rounding.
Más respuestas (1)
Star Strider
el 6 de Mzo. de 2015
One reason the recovered cosine is different from the original one is that it isn’t the original one:
x_2=cos(2*pi*(500+50*S)*t);
x=x_2+exp(-200*abs(t));
After taking the forward and reverse Fourier transforms, you’re comparing ‘x_2’ as your original signal, with ‘z’, a filtered version of ‘x’. If you plot both of these original signals, you will see that they are quite definitely not the same, so you wouldn’t expect their reconstructions to be the same.
The fftshift and ifftshift operations may also be causing problems. When I removed both, I got much more faithful reconstructions than I did with them included.
Ver también
Categorías
Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!