FFT for a single frequency
It's certainly calculating the right thing.  Though instead of

sum(x.*(cos(1000*2*pi*t)-i*sin(2*pi*1000*t)))*2/N;


you might try

sum(x.*exp(-i*2*pi*1000*t))*2/N;


If you need to do something similar, but in-line (not in a batch), you might want to look at the Goertzel algorithm. As the Wikipedia link says:


  .. provides a means for efficient evaluation of individual terms of the Discrete Fourier Transform


And there's nothing particularly "Fast" about this way of doing it, so it's really just calculating one DFT bin.