title: Extra explanation concerning the mathwork example on using matlab fft
body: <p>can someone explain why the result of an fft need to be divided by the number of sampling points (length of the signal)?</p>
  
  <p>The example can be found on this page: <a href="https://fr.mathworks.com/help/matlab/ref/fft.html" rel="nofollow noreferrer">https://fr.mathworks.com/help/matlab/ref/fft.html</a></p>
  
  <pre><code>Fs = 1000;            % Sampling frequency                    
  T = 1/Fs;             % Sampling period       
  L = 1500;             % Length of signal
  t = (0:L-1)*T;        % Time vector
  
  S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
  Y = fft(S);
  
  P2 = abs(Y/L);
  
  P1 = P2(1:L/2+1);
  </code></pre>
  
  <p>Why do they include this operation: <code>P2 = abs(Y/L);</code>?</p>
  
  <p>They do it for each example in the link. </p>
  
  <p>Also, why wouldn't they include that operation directly in the in-built fft function if they have to perform that operation after each fft calculation? 
  Are there some cases where it's better not to perform that extra operation?.</p>
  
  <p>Thanks!</p>