How to plot DFT (Discrete Fourier Transform) and IDFT (Inverse Discrete Fourier Transform) using MATLAB

1.Introduction:-
DFT is very important type of fourier transform which is use for fourier analysis in many application. It is used to determine frequency component in time domain signal.



2.Problem Statement:-
To find DFT using MALAB and plot phase spectrum and magnitude plot.


3.Program:-

clc;
clear all;
close all;
x=input('enter the sequemce')
N=length(x);
for n=0:N-1
  for k=0:N-1
    wnk(n+1,k+1)=exp(-i*2*pi.*n.*k/N);
  end
end
dft=wnk*x';
display('dft of sequence is')
display(dft)
%plot original signal
n=0:N-1;
subplot(2,2,1)
stem(n,x)
xlabel('discrete time n')
ylabel('amplitude')
title('original signal')
% magnitude plot
k=0:N-1;
subplot(2,2,2)
stem(k,abs(dft))
xlabel('discrete frequency k')
ylabel('amplitude')
title('magnitude plot')
% phase spectrume
k=0:N-1;
subplot(2,2,3)
stem(k,angle(dft))
xlabel('discrete frequency k')
ylabel('amplitude')
title('phase spectrune')
%inverse dft
x1=(1/N).*conj(wnk)*dft;
display('inverse dft of sequence is')
display(x1)
subplot(2,2,4)
stem(n,x1)
xlabel('discrete time n')
ylabel('amplitude')
title('inevrse signal signal')


4.How to use this code:-
Here you have to only copy the code to MATLAB and just run it and after this you have to give the values of input sequence which DFT you have to find.


5.Output :-

 Figure Window  
                                 


Command Window

                                                      



6.Conclusion -
Here we have successfully plot the magnitude plot and phase spectrum and find DFT and Inverse DFT.

Comments

Popular post

How to add ,read,insert IMAGE in MATLAB

How to plot different discrete signal using MATLAB

How to do Frequency Shift Keying (FSK) using MATLAB