title: Matlab fft on one period of sinewave returns phase of -pi/2. Why?
body: <p>While trying to understand Fast Fourier Transform I encountered a problem with the phase. I have broken it down to the simple code below. Calculating one period of a 50Hz sinewave, and applying an fft algorithm:</p>
  
  <pre><code>    fs = 1600;
      dt = 1/fs;
      L  = 32;      
      t=(0:L-1)*dt; 
      signal  = sin(t/0.02*2*pi); 
  
      Y = fft(signal);
      myAmplitude = abs(Y)/L *2 ;
      myAngle     = angle(Y);
  
      Amplitude_at_50Hz = myAmplitude(2);
      Phase_at_50Hz     = myAngle(2);
  </code></pre>
  
  <p>While the amplitude is ok, I don't understand the phase result. Why do I get -pi/2 ? As there is only one pure sinewave, I expected the phase to be 0. Either my math is wrong, or my use of Matlab, or both of them... (A homemade fft gives me the same result. So I guess I am stumbling over my math.)</p>
  
  <p>There is a similar post here: <a href="https://stackoverflow.com/questions/10268037/matlab-fft-phase-plot">MATLAB FFT Phase plot</a>. However, the suggested 'unwrap' command doesn't solve my problem.</p>
  
  <p>Thanks and best regards,</p>
  
  <p>DanK</p>