- 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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
David Young
2015-3-6
编辑:David Young
2015-3-6
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.
更多回答(1 个)
Star Strider
2015-3-6
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!