How to scale the plot of an Inverse Fast Fourier Transform?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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))
0 Kommentare
Akzeptierte Antwort
Matt J
am 7 Jul. 2013
Bearbeitet: Matt J
am 7 Jul. 2013
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])
3 Kommentare
Matt J
am 7 Jul. 2013
Bearbeitet: Matt J
am 7 Jul. 2013
Why does it not seem to effect the graphs at all when eta is adjusted?
I definitely see a change in I_lambda as eta is varied over 0, 1/T^2, 5/T^2.
abs(ifftE_t) seems to be invariant to eta for some reason, but real(ifftE_t) is not.
is there 1i? is that just a mistake or...?
It's the recommended way to express sqrt(-1). Supposedly, MATLAB processes it faster. It also allows you to use i as a variable without creating conflict, e.g.,
>> i=3; c=i+2i
c =
3.0000 + 2.0000i
why did -(w-w0).^2 switch to just -(w).^2?
Personal preference. A shift in frequency doesn't affect abs(ifftE_t), so it didn't matter.
Weitere Antworten (1)
Matt J
am 6 Jul. 2013
Bearbeitet: Matt J
am 6 Jul. 2013
There is no standardized way of scaling Fourier transforms. Different professions scale it differently. If you are using the engineering profession's definition of the continuous inverse Fourier transform, you can approximate it as
ifft(X)/dt
where dt is the sampling interval in the time domain.
However, you have bigger problems in your code. Your sampling interval, dt, is a vector for some reason, instead of a scalar
>> size(dt)
ans =
1 4096
which among other things means that the following line doesn't make sense
t = (-T1/2+dt:dt:T1/2);
Colon operations a:b:c are meant to be done with scalar a,b,c.
3 Kommentare
Matt J
am 7 Jul. 2013
Bearbeitet: Matt J
am 7 Jul. 2013
You should probably also be doing the ifft as follows
ifftE_t = fftshift(ifft(ifftshift(E_w))/dt);
I still don't know why you have
Fs = w/(2*pi); % sampling frequency
Since w is a vector, your sampling frequency Fs will be a vector as well, which wouldn't make sense. I still also don't understand how you can generate w according to
w = (2.*pi.*c)./lambda;
since this will give you non-equispaced samples in w. You need to decide on a scalar dw first and then generate equi-spaced w, something like
N=nfft;
dw=mean(diff(2*pi*c./lambda)); %just an example dw
w=dw*(0:N-1) -ceil((N-1)/2);
Then for the time axis. you would do
dt=1/N/dw;
timeAxis=dt*( (0:N-1) -ceil((N-1)/2) );
Siehe auch
Kategorien
Mehr zu Hilbert and Walsh-Hadamard Transforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!