Dear friends, I done FFTs of good known functions from Fourier Transform pairs table. The result of FFT doesn't match analytic transform in most cases by magnitude value, and in example 4 also by envelopment form. Code examples below. Where I wrong, please ?
fs=1000; % sampling rate
dt=1/fs; % time step
Sec=5; % Signal length
N=Sec*fs; % number of samples
n=(0:N-1)-N/2;tn=n*dt; % Time axis
df = fs/N; % Frequency resolution
fk=n*df; % Frecuency axis [Hz]
wk=fk*2*pi; % Angular frequency axis [Rad/sec]
%--------------
% Example 1
% Time domain
alfa=7;ex1=exp(-alfa.*abs(tn));% FFT result
Ex1a=fftshift(fft(ifftshift(ex1)));% Analytics Fourier transform
Ex1b=(2*alfa)./((alfa^2)+(wk.^2));figure(1);subplot(3,1,1);plot(tn,ex1); grid;title('e^{-a|t|}');subplot(3,1,2);plot(wk,real(Ex1a));grid;title('Ex1a');subplot(3,1,3);plot(wk,real(Ex1b));grid;title('2a/(a^2+w^2)');%--------------% Example 2
% Time domainsigma=0.5;ex2=exp(-(tn.^2)/(2*(sigma^2)));% FFT resultEx2a=fftshift(fft(ifftshift(ex2)));% Analytics Fourier transformEx2b=sigma*sqrt(2*pi)*exp(-(sigma^2).*(wk.^2)/2);figure(2);subplot(3,1,1);plot(tn,ex2);grid;title('e^{-t^2/2s^2}');subplot(3,1,2);plot(wk,real(Ex2a));grid;title('Ex2a');subplot(3,1,3);plot(wk,real(Ex2b));grid;title('s*sqrt(2pi)*e^{-s^2w^2/2}');%--------------% Example 3
% Time domainex3=1i./(pi.*tn);% FFT resultEx3a=fftshift(fft(ifftshift(ex3)));% Analytics Fourier transformEx3b=-1*(wk<0)+1*(wk>0);figure(3);subplot(3,1,1);plot(tn,abs(ex3));grid;title('-i/(t*pi)');subplot(3,1,2);plot(wk,real(Ex3a));grid;title('Ex3a');subplot(3,1,3);plot(wk,real(Ex3b));grid;title('(w<0)=>-1;(w>0)=>1');%--------------% Example 4
% Time domainex4=cos(alfa.*(tn.^2));% FFT resultEx4a=fftshift(fft(ifftshift(ex4)));% Analytics Fourier transformEx4b=sqrt(pi/alfa)*cos((wk.^2)/4/alfa-pi/4);figure(4);subplot(3,1,1);plot(tn,ex4);grid;title('cos(a*t^2)');subplot(3,1,2);plot(wk,abs(Ex4a));grid;title('Ex4a');subplot(3,1,3);plot(wk,abs(Ex4b));grid;title('sqrt(pi/a)*cos(w^2/4a-pi/4)');%--------------% Example 5
% Time domainex5=2*cos(2*pi*4*tn)+3*cos(2*pi*7*tn);% FFT resultEx5a=fftshift(fft(ifftshift(ex5)));figure(5);subplot(2,1,1);plot(tn,ex5);grid;title('2cos(4wt)+3cos(7wt)');subplot(2,1,2);plot(wk,abs(Ex5a));grid;title('Delta(-14pi)+Delta(-8pi)+Delta(8pi)+Delta(14pi)');
Best Answer