Why is my graph from my IFFT not working?
조회 수: 5 (최근 30일)
이전 댓글 표시
I have an initially electric field in the frequency domain that I am trying to get into the time domain with an ifft, and compare that to the analytically calculated graph that I am suppose to get. Although, when I plot the ifft it looks nothing like what I am suppose to be getting.
% Constants
c = 299792458; % speed of light in a vacuum
FWHM = 30e-15; % pulse duration
T = FWHM/(2*(sqrt(log(2)))); % (T=tau)
lambda0 = 800e-9; % central wavelength
w0 = (2*pi*c)/lambda0; % central angular frequency
phi_w = 0; % phase (in time or freqency)
eta = 0; % chirp (2nd derivitive of phase)
% electric field and intensity in wavelength domain
nfft = 2^12;
lambda = (740e-9:((120e-9)/(nfft-1)):860e-9);
w = (2.*pi.*c)./lambda;
E_w = (1/(sqrt((1/T.^2)+i*eta)))*exp((-(w-w0).^2)/((2/T.^2)+2*i*eta));
I_lambda= (abs(E_w)).^2;
% IFFT
dw = w(2)-w(1); % difference in frequency
ifftE_t =(ifft(E_w))*dw; % ifft
Ts = 1/dw; % sampling time
dt = Ts/length(E_w); % difference in sampling time
time = -Ts/2+dt:dt:Ts/2; % time
% (test to see if inverse fourier matches)
t = -100e-15:1e-15:100e-15;
PE_t =exp((-t.^2/(2*T.^2)) + (i*w0*t-(1/2)*i*eta*t.^2)); %*phi_t));
% PLOT
subplot(3, 1, 1);
plot(lambda, I_lambda);
title('Gaussian Pulse Signal');
xlabel('Wavelength');
ylabel('I_\lambda');
subplot(3, 1, 2)
plot(time, real(ifftE_t))
set(gca,'xlim',[-1 1]);
subplot(3, 1, 3);
plot(t, PE_t)
xlabel('t');
ylabel('I_t');
댓글 수: 1
Jan
2013년 7월 5일
@Joe: Please note that we cannot guess, what you are supposed to be getting. Therefore we cannot guess the difference between the results of your code and your expectations.
채택된 답변
Matt J
2013년 7월 5일
편집: Matt J
2013년 7월 5일
Your dw, and hence also your Ts, are negative,
>> dw, Ts
dw =
-1.0080e+11
Ts =
-9.9209e-12
Your frequency samples w(i) are also non-uniformly spaced, which throws the use of FFTs into question. FFTs are approximations to continuous Fourier transforms only when the data is uniformly sampled.
Finally, be mindful that your frequencies are interpreted as Hertz by MATLAB, not radian frequency.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!