Going from FFT to IFFT, shouldn't I get the same graph I initially started with?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have the code below where I am converting electric field in the frequency domain to the time domain and back to the frequency domain. I don't know why I am not getting the same graph I started with after my FFT and IFFT. Any help is much appreciated.
% 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 wavelngth
w0 = (2*pi*c)/lambda0; % central angular frequency
phi_t = 0; % phase (in time or freqency)
eta = 0; % chirp (2nd derivitive of phase)
lambda = (740e-9:20e-9:860e-9); % wavelength interval
w = (2.*pi.*c)./lambda; % angular frequency conversion
% electric field in the time domain
E_t = exp((-t.^2/(2*T.^2)) + (i*w0*t-(1/2)*i*eta*t.^2)); %*phi_t));
% FFT
dt = t(2)-t(1); % difference in time (T)
E_w = (fftshift(fft(E_t)))*dt; % fft
Fs = 1/dt; % sampling frequency
df = Fs/length(E_t); % difference in sampling frequency
freq = -Fs/2+df:df:Fs/2; % frequency
lambda = c./freq; % wavelength
I_w = abs(E_w).^2; % intensity
% 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
% PLOT
subplot(3, 1, 1);
plot(t, real(E_t));
title('Gaussian Pulse Signal');
xlabel('time (s)');
ylabel('E_t');
subplot(3, 1, 2);
plot(lambda,I_w);
set(gca,'xlim',[0 9e-7]);
title('FFT')
xlabel('\lambda');
ylabel('I_\lambda');
subplot(3, 1, 3)
plot(time, real(ifftE_t))
title('IFFT')
xlabel('time (s)')
ylabel('E_t')
0 commentaires
Réponse acceptée
Walter Roberson
le 5 Juil 2013
You used fftshift() on the results of the fft(), but you did not fftshift() back before doing the ifft()
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!