title: fft/ifft: Sampling Frequency and Length of Signal
body: <p>This is partly taken from the Matlab fft-documentation: </p>
  
  <pre><code>Fs = 30;                    % Sampling frequency
  T = 1/Fs;                   % Sample time
  L = 130;                    % Length of signal
  t = (0:L-1)*T;              % Time vector
  
  x = sin(2*pi*1*t);          % 1 Hz sinus
  
  plot(real(ifft(abs(fft(x))))); % fft then ifft
  
  % Fs = 30, L = 60 / 90 / 120 ... : ok
  % Fs = 20, L = 60 / 80 / 100 ... : ok
  % Fs = 30, L = 50 / 70 / 80 ... : not ok
  </code></pre>
  
  <p>It seems to me that whenever the length of the signal is a multiple of the sampling frequency, the sinusoid is reconstructed correctly (apart from some shift), e.g. here <code>Fs = 30, L = 60</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/6OvoH.png" alt="enter image description here"></p>
  
  <p>However, if for example <code>Fs = 30, L = 80</code> (not a multiple), the result looks odd: </p>
  
  <p><img src="https://i.stack.imgur.com/m2Ypj.png" alt="enter image description here"></p>
  
  <p>Is this behaviour correct? Why is this happening and how can I avoid this? Just throw away some part of the signal such that the length "fits" the sampling frequency?</p>