Why do i have to take the abs when using fft and ifft?
古いコメントを表示
I have a simple code to test how matlab processes the fft and ifft command:
clear all
close all
N=1e4;
dx=0.01;
Axis=(-ceil(N/2):ceil(N/2));
x=dx*Axis;
y=exp(-(x.^2)/(2*(1^2)));
Fy=fftshift(abs(fft(y)));
IFy=ifftshift(abs(ifft(Fy)));
y1=exp(-((x-3).^2)/(2*(1^2)))+ exp(-((x+3).^2)/(2*1^2)));
Fy1=fftshift((fft(y1)));
IFy1=abs(ifft(Fy1));
figure(1)
subplot(311);
plot(x,y)
subplot(312)
plot(x,Fy)
subplot(313)
plot(x,IFy)
figure(2)
subplot(311);
plot(x,y1)
subplot(312)
plot(x,Fy1)
subplot(313)
plot(x,IFy1)
Firstly, why in the first case, figure 1, do i have to take the abs in the fft and ifft. the fourier of a gaussian is a gaussian and the abs should not have to be taken.
Second, in the second case why can i not use the same code. ie why does the abs have to be left out in the fft and there is still a warning once run:
Warning: Imaginary parts of complex X and/or Y arguments ignored
> In Untitled at 38
採用された回答
その他の回答 (1 件)
Walter Roberson
2011 年 5 月 31 日
0 投票
The fourier of a gaussian might be a gaussian, but your data is only the approximation of a gaussian.
3 件のコメント
Brenden
2011 年 5 月 31 日
Walter Roberson
2011 年 5 月 31 日
One does not get false graphs: one gets correct graphs for the data that was input. fft() cannot (and *should not*) do anything to "correct" the data input to it.
Brenden
2011 年 5 月 31 日
カテゴリ
ヘルプ センター および File Exchange で Discrete Fourier and Cosine Transforms についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!