Using ifft to Recover Cosine from Two Delta Impulses

2 vues (au cours des 30 derniers jours)
Pyro
Pyro le 6 Mar 2015
Modifié(e) : Pyro le 6 Mar 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?

Réponse acceptée

David Young
David Young le 6 Mar 2015
Modifié(e) : David Young le 6 Mar 2015
There are a number of reasons for the differences:
  • 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.
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.

Plus de réponses (1)

Star Strider
Star Strider le 6 Mar 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.
  1 commentaire
Pyro
Pyro le 6 Mar 2015
Actually, I used a BPF to get my cosine back, and the recovered spectrum matches the original spectrum of my cosine.
However, the problem is that the recovered cosine in the time domain resembles the absolute value of the original cosine.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by