title: Finding the phase from FFT on MATLAB
body: <p>I know the fundamental frequency of my signal and therefore I also know the other frequencies for the harmonics, I have used the FFT command to compute the first 5 harmonics (for which I know their frequencies). Is it possible for me to find the phase with this available information?</p>
  
  <p>Please note I cant be sure my signal is only one period and therefore need to calculate the phase via the known frequency values.</p>
  
  <hr>
  
  <p>Code seems to be working:</p>
  
  <pre><code> L = length(te(1,:));               % Length of signal
   x = te(1,:); 
   NFFT = 2^nextpow2(L);              % Next power of 2 from length of y
   Y = fft(x,NFFT)/L;
   f = linspace(1,5,5);   
   Y(1) = [];                          % First Value is a sum of all harmonics
   figure(1);
   bar(f,2*abs(Y(1:5)), 'red') 
   title('Transmission Error Harmonics')
   xlabel('Harmonic')
   ylabel('|Y(f)|')
   figure(2);
   bar(f,(angle(Y(1:5))))
   title('Transmission Error Phase')
   xlabel('Harminic')
   ylabel('Angle (radians)')
  </code></pre>