# can't get the right spectrum in scilab

I'm trying to write a simple script that should plot the spectrum in scilab, to test it I use a sinus function with 440hz so that I get my dirac in this position , my problem is that it doesn't work and I don't understand why? here's the code :

Fs = 8000;
f = 440;
t= 0:1/Fs:1;
y = sin(2*%pi*f*t);

nf = 1024; // number of point in the DFT
Y = fft(y)
f = Fs/2  * linspace(0,1,nf/2+1);
clf();
plot(f,abs(Y(1:nf/2+1)));


and this is what I get :

any idea why I get this ?

• No, the FFT computes the discrete Fourier transform (DFT), and in this case you get an impulse with height $N/2$ (where $N$ is the FFT length). However, you only get a discrete impulse in the frequency domain if your signal frequency lies on the grid of FFT frequencies (i.e. $N$ is an integer multiple of the period of the time signal). Hope this helps. Mar 4 '14 at 12:05