MATLAB: How to scale the plot of an Inverse Fast Fourier Transform

ifftplottingscaling

Hi, I'm not sure how to get my scaling right in my ifft from frequency to time when I plot it. I've tried below, but I know something is off from the graph. Thanks.
% 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
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
Fs = w/(2*pi); % sampling frequency
df = Fs/nfft;
dw = 2*pi*df;
dt = 1./Fs; % increments of time
T1 = (nfft*dt);
t = (-T1/2+dt:dt:T1/2);
ifftE_t = ifft(E_w); % ifft
% PLOT
subplot(2, 1, 1);
plot(w, I_lambda);
title('Gaussian Pulse Signal');
xlabel('Wavelength');
ylabel('I_\lambda');
subplot(2, 1, 2)
plot(t, abs(ifftE_t))

Best Answer

The following modification seems to work for me. I get Gaussian-looking pulses in both the time and frequency domain, exactly as expected for eta=0.
% 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
eta = 0; % chirp (2nd derivitive of phase)
% electric field and intensity in wavelength domain
f0=w0/(2*pi);
L=(1/FWHM); %order of magnitude of pulse duration in frequency space
df=L/10000;
Df=5*L; %frequency duration
N=ceil(Df/df);
dt=1/N/df;
NormalizedAxis= (0:N-1) -ceil((N-1)/2);
t=dt*NormalizedAxis;
f=df*NormalizedAxis;
w=2*pi*f;
dw=2*pi*df;
% Spectra
E_w = (1/(sqrt((1/T.^2)+1i*eta)))*exp((-(w).^2)/((2/T.^2)+2*1i*eta));
I_lambda= (abs(E_w)).^2;
% IFFT
ifftE_t = fftshift(ifft(E_w))/dt; % ifft
% PLOT
subplot(2, 1, 1);
plot(w+w0, I_lambda);
title('Gaussian Pulse Signal');
xlabel('Wavelength');
ylabel('I_\lambda');
subplot(2, 1, 2)
plot(t, abs(ifftE_t)); xlim(FWHM*[-5,5])