title: How to find the period of a periodic function using FFT?
body: <p>Assume I have a smooth function (represented as a vector):</p>
  
  <pre><code>x=0:0.1:1000; 
  y=sin(2*x); 
  </code></pre>
  
  <p>and I want to find its periodicity - pi (or even its frequency -2 ) .
  I have tried the following:</p>
  
  <pre><code>nfft=1024;
  Y=fft(y,nfft);
  Y=abs(Y(1:nfft/2));
  plot(Y);
  </code></pre>
  
  <p>but obviously it doesn't work (the plot does not give me a peak at "2" ).</p>
  
  <p>Will you please help me find a way to find the value "2"?</p>
  
  <p>Thanks in advance </p>