title: the Length of signal in calculating FFT
body: <p>I want to ask some questions related to the last question of mine so I don't want to post in another thread. My question contains a code, I therefore can't post it as a comment. So I have to edit my old question into a new one. Please take a look and help. Thank you.</p>
  
  <p>I'm new to FFT and DSP and I want to ask you some questions about calculating FFT in Matlab. The following code is from Matlab help, I just removed the noise.</p>
  
  <ol>
  <li><p>Can I choose the length of signal L different from NFFT?</p></li>
  <li><p>I'm not sure if I used window correctly. But when I use window (hanning in the following code), I can't get the exact values of amplitudes?</p></li>
  <li><p>When L and NFFT get different values, then the values of amplitudes were different too. How can I get the exact value of amplitude of input signal? (in the following code, I used a already known signal to check if the code work correctly. But in case, I got the signal from a sensor and I dont know ahead its amplitude, how can I check?)</p></li>
  </ol>
  
  <p>I thank you very much and look forward to hearing from you :)</p>
  
  <pre><code>Fs = 1000;                    % Sampling frequency
  T = 1/Fs;                     % Sample time
  L = 512;                     % Length of signal
  NFFT=1024;                   % number of fft points
  t = (0:L-1)*T;                % Time vector
  x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);    input signal
  X = fft(hann(L).*x', NFFT)/L;
  f = Fs/2*linspace(0,1,NFFT/2+1);
  plot(f,2*abs(X(1:NFFT/2+1)))     % Plot single-sided amplitude spectrum.
  </code></pre>