I have a function defined like: $$x(t)=2e^{-\frac{r}{2}t}\sin\left(\frac{1}{2}\sqrt{16\pi^2-r^2}\cdot t\right)\left(\frac{\Theta(t)}{\sqrt{16\pi^2-r^2}}\right) $$ Where $\Theta(t)$ is the Heaviside Theta funcion. If I perform the Fourier Transform of x(t) I have: $$X(\omega)=\frac{2 \sqrt{\frac{32 \pi -\frac{1}{2 \pi }}{16 \pi ^2-\frac{1}{4}}}}{-4 \omega^2-2 i \omega+16 \pi ^2}$$ Now I define on Matlab $t=linspace(0,10,2^8)$, and $y=fft(x(t))$ and try to plot the analytical $X(\omega)$ with the coefficient by fft but but they are differnt. Can someone suggest me a good way to do?
Here is my code :
x=@(t)2*e.^(-r/2*t).*sin(1/2*sqrt(16*pi^2-r.^2).*t).*...
(1*heaviside(t))./(sqrt(16*pi^2-r.^2));
e=exp(1); M=1; K=4*pi^2; C=1/2;
om=sqrt(4*K-C^2)/2; t=linspace(0,10,2^7);
punti=x(t); N=length(punti); FFT=fft(punti);
pseudoperiodo=2*pi/om;
dw=(2*pi)/pseudoperiodo;
N=length(punti); FFT=FFT/N; % calculate coefficient
w=dw*[[0:N/2],-[N/2-1:-1:1]]';
figure
plot(w(1:N/2+1),abs(FFT(1:N/2+1)),'o')
figure
G=tf(1,[M C K]); bode(G)