Clear Filters
Clear Filters

Why does "Amplitude Scale Factor of FFT" depend on data?

6 views (last 30 days)
% November 14, 2013 -
% Here, 2 functions were sampled using same sampling frequncy and record length.
% Next, data were fed to fft.
% However, their absolute value of fft output (i.e., amplitude) needs to be scaled differently.
% This suggest fft applies different numerical algorithms to data even they share same sampling frequency and record length.
%
% This file plots FFT amplitude for 2 functions:
%
% 1. Sine Function: Y(t)=sin(2*pi*f0*t)
% 2. Sinc Function: Y(t)=sin(2*pi*f0*t)./(pi*t) if t~=0,
% =2*f0 if t==0
%
% Both functions are sampled at same frequncy and share same record length.
% However, amplitude needs to be scaled differently:
%
% 1. Amplitude of FFT(sine) needed to be multiplied by 2/(Record Length -1)
% Furthermore, the amolitude at zero frequncy must also be divided by 2.
%
% 2. Amplitude of FFT(sinc) needed to be multiplied by sampling time
%
clear
close all
% Setting frequency of sine and sinc
f0=2;
% Defining sampling rate and time vector in seconds
t_samp=0.05;
t_length=1000;
t=-t_length:t_samp:t_length;
% Frequency Vector
f=-1/t_samp/2:1/t_samp/max(size(t)-1):1/t_samp/2;
% Sampling sine and sinc function for f0=1Hz.
y_sine=sin(2*pi*f0*t);
y_sinc=sin(2*pi*f0*t)./(pi*t);
% Sinc needs to be set to 2*f0 at t=0.
loc=find(t==0);
y_sinc(loc)=2*f0;
% FFT
FFT_sine=fft(y_sine);
FFT_sinc=fft(y_sinc);
% Calculating Amplitude
Amp_FFT_sine=abs(FFT_sine);
Amp_FFT_sinc=abs(FFT_sinc);
%%%%%Beginning of Amplitude Scaling:
% For sine function, zero frequnecy amplitude must be divided by 2
% Sinc function does not need that
Amp_FFT_sine(1)=Amp_FFT_sine(1)/2;
% Sine and sinc need to be scaled differently
Amp_FFT_sine=Amp_FFT_sine*(2/max(size(t)-1));
Amp_FFT_sinc=abs(Amp_FFT_sinc)*t_samp;
%%%%%End of Scaling
% Shifting zero frequncy to center
Amp_FFT_sine=fftshift(Amp_FFT_sine);
Amp_FFT_sinc=fftshift(Amp_FFT_sinc);
% Plotting
figure(1)
h0=subplot(2,1,1);
hold
set(h0,'FontSize',14)
set(h0,'FontWeight','b')
h1=plot(f,Amp_FFT_sine);
set(h1,'LineWidth',2)
set(h1,'color','r')
set(h0,'XTick',[min(f),-f0,0,f0,max(f)]);
set(h0,'YTick',[0,1,2])
axis([min(f),max(f),0,2])
grid on
legend('Fourier Transform of {sin(2*pi*f_0*t)}')
title(strcat('f_0=',num2str(f0),'Hz'))
ylabel('Amplitude')
h00=subplot(2,1,2);
hold
set(h00,'FontSize',14)
set(h00,'FontWeight','b')
h2=plot(f,Amp_FFT_sinc);
set(h2,'LineWidth',2)
set(h2,'color','k')
set(h00,'XTick',[min(f),-f0,0,f0,max(f)])
set(h00,'YTick',[0,1,2])
axis([min(f),max(f),0,2])
grid on
legend('Fourier Transform of {sin(2*pi*f_0*t)/(pi*t)}')
ylabel('Amplitude')
xlabel('Frequency [Hz]')
  2 Comments
Muthu Annamalai
Muthu Annamalai on 14 Nov 2013
You mean scale factor and how it depends on the number of points? Well thats what it takes for FFT/IFFT to be a pair of unitary transformations.

Sign in to comment.

Answers (1)

shirish pataki
shirish pataki on 10 Jul 2018
Edited: shirish pataki on 10 Jul 2018
You can check following answer: We scale the amplitude in FFT domain just to satisfy the parsevel's relation (the law of conservation of energy). (I am unable to write the equation here however you can find that anywhere on google). Parsevel's relation says that in FFT domain the Energy/power is scaled by N to maintain same energy as time domain. In sinc i.e Sin x/ (Pi. x) treat it as two signal division. Therefore as per Parsevels relation, in FFT domain it is scaling by N/N thus scaling by 1. Thus in sinc you need not divide/scale the amplitude of FFT by FFT length but for FFT of sin you need to divide/scale.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!