Why FFT function returns amplitude divided by 2 ?
    조회 수: 10 (최근 30일)
  
       이전 댓글 표시
    
Hello,
I doesn't understand the amplitude given by the FFT function. Indeed I use it to calculate the DFT of a sum of sine and the amplitude returned is divided by 2 wrt the amplitude of my original function. The frequencies are correct
Does anyone can explain it to me ?
Please find hereunder the code I used :
T = 0:0.01:10;
T = T';
x1 = 0.5*sin(2*pi*2*T);
x2 = 1.2*sin(2*pi*5.4*T);
x3 = 0.7*sin(2*pi*7*T);
y = x1+x2+x3;
N = length(y);
duree = max(T)-min(T);
Delta_T = duree/N;
Fe = N/duree;
Delta_F = 1/duree;
xfft = 1/N*fft(y);
mag = abs(xfft);
freq = 0:Delta_F:(Fe-Delta_F);
freq = freq';
figure(2)
hold all;
plot(freq,mag);
legend('abs');
xlabel('Freq in Hz');
title('FFT');
box on;
set(gca,'Xlim',[0 100]);
grid on;
figure(1)
hold all;
plot(T,y)
grid on
댓글 수: 0
채택된 답변
  Wayne King
    
      
 2013년 8월 6일
        
      편집: Wayne King
    
      
 2013년 8월 6일
  
      Because the discrete Fourier transform matches the input signal with complex exponentials and a cosine is the sum of two complex exponentials divided by 2. The same is true of a sine (except it's divided by 2i)
That is where the factor of 1/2 is coming from. Since you have a real-valued signal, if you are only interested in looking at the magnitude, you can just keep the "positive" frequencies and scale them by 2.
   T = 0:0.01:10-0.01;
   T = T';
   x1 = 0.5*sin(2*pi*2*T);
   x2 = 1.2*sin(2*pi*5.4*T);
   x3 = 0.7*sin(2*pi*7*T);
   y = x1+x2+x3;
   N = length(y);
   duree = max(T)-min(T);
   Delta_T = duree/N;
   Fe = N/duree;
   Delta_F = 1/duree;
   xfft = 1/N*fft(y);
   magfft = abs(xfft);
   magfft = magfft(1:length(xfft)/2+1);
   magfft(2:end-1) = 2*magfft(2:end-1);
   freq = 0:100/length(y):100/2;
   plot(freq,abs(magfft))
   grid on;
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Transforms에 대해 자세히 알아보기
			
	제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

