title: Matlab, FFT frequency range differences or are they the same?
body: <p>I'm trying to understand how the FFT in matlab works, particularly, how to define the frequency range to plot it. It happens that I have read from matlab help links and from other discussions here and I think (guess) that I'm confused about it.
  In the matlab link:
  <a href="http://es.mathworks.com/help/matlab/math/fast-fourier-transform-fft.html" rel="nofollow noreferrer">http://es.mathworks.com/help/matlab/math/fast-fourier-transform-fft.html</a>
  they define such a frequency range as:</p>
  
  <pre><code>f = (0:n-1)*(fs/n)
  </code></pre>
  
  <p>with <code>n</code> and <code>fs</code> as:</p>
  
  <pre><code>n = 2^nextpow2(L); % Next power of 2 from length of signal x
  fs = N/T; % N number of samples in x and T the total time of the recorded signal
  </code></pre>
  
  <p>But, on the other hand, in the previous post  <a href="https://stackoverflow.com/questions/10758315/understanding-matlab-fft-example">Understanding Matlab FFT example</a>
  (based on previous version of matlab), the resulting frequency range is defined as:</p>
  
  <pre><code>f = fs/2*linspace(0,1,NFFT/2+1);
  </code></pre>
  
  <p>with <code>NFFT</code> as the aforementioned <code>n</code> (Next power of 2 from length of signal <code>x</code>).
  So, based on that, how these different vectors (equation 1 and final equation) could be the same?
  If you can see, the vectors are different since the former has <code>n</code> points and the later has <code>NFFT/2</code> points! In fact, the factor <code>(fs/n)</code> is different from <code>fs/2</code>.</p>