Why do we use ifft instead of fft when looking at the spectrum of a sech pulse (uu) in this code?
In the code below, temp = fftshift(ifft(uu)) is used to view the sech pulse in the spectrum. However, since ifft is a function that transforms from the frequency domain to the time domain, wouldn’t temp = fftshift(fft(uu))) be correct? Why does the book do it this way?
% SSFM code for solving the normalized NLS equation
%% By G. P. Agrawal for the 6th edition of NLFO book
fiblen = 5;
beta2 =-1;
N = 1;
% fiber length (in units of L_D)
% sign of GVD parameter beta_2
% soliton order
%—set simulation parameters
nt = 1024; Tmax = 32;
% FFT points and window size
step_num = round(20*fiblen*N^2);
% No. of z steps
deltaz = fiblen/step_num; % step size in z
dtau = (2*Tmax)/nt;
tau = (-nt/2:nt/2-1)*dtau;
% step size in tau
% time array
omega = fftshift(-nt/2:nt/2-1)*(pi/Tmax); % omega array
uu = sech(tau);
% sech pulse shape (can be modified)
%—Plot input pulse shape and spectrum
temp = fftshift(ifft(uu));
% Fourier transform
spect = abs(temp).^2;
spect = spect./max(spect);
freq = fftshift(omega)/(2*pi);
subplot(2,1,1);
% input spectrum
% normalize
% freq. array
plot(tau, abs(uu).^2, ‘–k’); hold on; axis([-5 5 0 inf]);
xlabel(‘Normalized Time’); ylabel(‘Normalized Power’);
subplot(2,1,2);
plot(freq, spect, ‘–k’); hold on; axis([-.5 .5 0 inf]);
xlabel(‘Normalized Frequency’); ylabel(‘Spectral Power’);In the code below, temp = fftshift(ifft(uu)) is used to view the sech pulse in the spectrum. However, since ifft is a function that transforms from the frequency domain to the time domain, wouldn’t temp = fftshift(fft(uu))) be correct? Why does the book do it this way?
% SSFM code for solving the normalized NLS equation
%% By G. P. Agrawal for the 6th edition of NLFO book
fiblen = 5;
beta2 =-1;
N = 1;
% fiber length (in units of L_D)
% sign of GVD parameter beta_2
% soliton order
%—set simulation parameters
nt = 1024; Tmax = 32;
% FFT points and window size
step_num = round(20*fiblen*N^2);
% No. of z steps
deltaz = fiblen/step_num; % step size in z
dtau = (2*Tmax)/nt;
tau = (-nt/2:nt/2-1)*dtau;
% step size in tau
% time array
omega = fftshift(-nt/2:nt/2-1)*(pi/Tmax); % omega array
uu = sech(tau);
% sech pulse shape (can be modified)
%—Plot input pulse shape and spectrum
temp = fftshift(ifft(uu));
% Fourier transform
spect = abs(temp).^2;
spect = spect./max(spect);
freq = fftshift(omega)/(2*pi);
subplot(2,1,1);
% input spectrum
% normalize
% freq. array
plot(tau, abs(uu).^2, ‘–k’); hold on; axis([-5 5 0 inf]);
xlabel(‘Normalized Time’); ylabel(‘Normalized Power’);
subplot(2,1,2);
plot(freq, spect, ‘–k’); hold on; axis([-.5 .5 0 inf]);
xlabel(‘Normalized Frequency’); ylabel(‘Spectral Power’); In the code below, temp = fftshift(ifft(uu)) is used to view the sech pulse in the spectrum. However, since ifft is a function that transforms from the frequency domain to the time domain, wouldn’t temp = fftshift(fft(uu))) be correct? Why does the book do it this way?
% SSFM code for solving the normalized NLS equation
%% By G. P. Agrawal for the 6th edition of NLFO book
fiblen = 5;
beta2 =-1;
N = 1;
% fiber length (in units of L_D)
% sign of GVD parameter beta_2
% soliton order
%—set simulation parameters
nt = 1024; Tmax = 32;
% FFT points and window size
step_num = round(20*fiblen*N^2);
% No. of z steps
deltaz = fiblen/step_num; % step size in z
dtau = (2*Tmax)/nt;
tau = (-nt/2:nt/2-1)*dtau;
% step size in tau
% time array
omega = fftshift(-nt/2:nt/2-1)*(pi/Tmax); % omega array
uu = sech(tau);
% sech pulse shape (can be modified)
%—Plot input pulse shape and spectrum
temp = fftshift(ifft(uu));
% Fourier transform
spect = abs(temp).^2;
spect = spect./max(spect);
freq = fftshift(omega)/(2*pi);
subplot(2,1,1);
% input spectrum
% normalize
% freq. array
plot(tau, abs(uu).^2, ‘–k’); hold on; axis([-5 5 0 inf]);
xlabel(‘Normalized Time’); ylabel(‘Normalized Power’);
subplot(2,1,2);
plot(freq, spect, ‘–k’); hold on; axis([-.5 .5 0 inf]);
xlabel(‘Normalized Frequency’); ylabel(‘Spectral Power’); nls, fiber simulation MATLAB Answers — New Questions