- 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!