MATLAB: Fourier transform of impulse function

fft

I calculated the Fourier transform of a pulse function(figure 1) Using the fft function. However The fft result if kind of weird. Can anyone check if my code is right. //Thanks
clc
clear all
close all
t1=7.0e-08;
sigma=1e-08;
t=linspace(0,4.0000e-7,1000);
P=exp(-(t-t1).^2./sigma.^2);
P_FT=fft(P); %fourier transform of P
figure(1)
plot(t*10^6,P);
grid on
xlabel('time[\mus]')
ylabel('amplitude[a.u]')
figure(2)
plot(P_FT);
grid on

Best Answer

The Fourier transform of an impulse function is uniformly 1 over all frequencies from -Inf to +Inf. You did not calculate an impulse function.
You calculated some sort of exponential function that will appear as an exponential function in the Fourier transform.
Your slightly modified code:
t1=7.0e-08;
sigma=1e-08;
L = 1000;
t=linspace(0,4.0000e-7,L);
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
P=exp(-(t-t1).^2./sigma.^2);
P_FT=fft(P)/L; %fourier transform of P
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure(1)
plot(t*1E+6, P);
grid on
xlabel('time[\mus]')
ylabel('amplitude[a.u]')
figure(2)
plot(Fv, abs(P_FT(Iv))*2);
grid on
The correct representation of the Fourier transform of your signal is in figure(2).
Related Question