Discrete Fourier Transform Matlab Program

Discrete Fourier Transform Matlab Program

fourier transform

Discrete Fourier transform is used to decompose time series signals into frequency components each having an amplitude and phase. Using the inverse Fourier transformation the time series signal can be reconstructed from its frequency-domain representation. Fourier transformation is one of the most important concepts in digital signal processing and is not only used for estimating the spectral distribution of a signal in the frequency domain (the power spectrum). Fourier transformation is also the foundation of coherence analysis and certain types of so called surrogate signals. Finally, the Fourier transformation is implemented in many DSP (Digital Signal Processing) routines because any mathematical operation in the time domain has an equivalent operation in the frequency  domain that is often computationally faster. Thus, Fourier transformation is occasionally implemented solely to speed up algorithms. Using the inverse Fourier transformation, the time-domain signal is reconstructed from its frequency domain representation.

Matlab allows us to perform almost all of the digital signal processing applications on software, which makes it a lot easier to study the principles of digital signal processing and digital communication. Matlab almost performs all the operations regarding audio video and signals. One of the most important feature of matlab is that we can plot our results and observe them which is difficult manually. Following is the program to generate a dft sequence and observe the output on the graph and verify the result manually

Comparison between FFT and DFT

The
Fourier transform is important in mathematics, engineering, and the physical
sciences.  Its discrete counterpart, the Discrete Fourier Transform (DFT),
which is normally computed using the so-called Fast Fourier Transform (FFT),
has revolutionized modern society, as it is ubiquitous in digital electronics
and signal processing.  Radio astronomers are particularly avid users of
Fourier transforms because Fourier transforms are key components in data
processing (e.g., periodicity searches) and instruments (e.g., antennas,
receivers, spectrometers), and they are the corner stores of interferometry and
aperture synthesis.

%% The Program Generates DFT of a Sequence
% Equation of DFT implemented as part of assignment
% The Function takes x as discrete time sequence input from user
% N point DFT is calculated for the same sequence
% N can be default equal to length(x) or any input from user of 2^
% Syntax of calling Function from other program or command prompt
% x=input('Enter the sequence from user');
% N1=input('Enter the N Point DFT of the sequence');
function [X]=mydft(x,N1)
% if length of N point DFT given by user,
% N will be calculted for length(x)
x=input('Enter the sequence from user');
N1=input('Enter the N Point DFT of the sequence')
len=length(x);
if N1<len
    N=len;
else
    N=N1;
end
% pre allocation of Variable X: Generation of zeros Matrix
X=zeros(1,N);
%% Computation of DFT of the sequence 
% X[k]=x[n]*exp(-j*2*pi*n*k);

%X[k]=x[n]*[cos(2*pi*n*k)-j*sin(2*pi*n*k)];
%X[k]=x[n]*W  where W=exp((-j*2*pi*n*k)/N);
% The limits of k, n can varied from 1:N hence in equation (k-1), (n-1)
% being used

for k=1:N
    for n=1:N
        X(1,k)=X(1,k)+x(n)*(cos((2*pi*(k-1)*(n-1))/N)-j*(sin((2*pi*(k-1)*(n-1))/N)));
    end
end

%% The results can be verified with built in function fft
X1=fft(x,N);

 

Output

Discrete fourier transform
You can directly copy paste this program in your Matlab Editor and run it, any queries and questions are welcome.
Also Check out

Leave a Reply


Are You in Search
of A Job?

Subscribe to get job Alerts straight to your email inbox absolutely Free!

Thank you for subscribing.

Something went wrong.