dftidft2 clc clear all close all X=input( 'Enter the Input Sequence' ); N=input( 'Enter the N value such that N-point DFT is calculated' ); %Inputs are given% L=length(X); if N>L X=[X zeros(1,N-L)]; else X=X(1:N); end %Adjusting the Length of the input Sequence by appending Zeros or truncating the sequence% for k=1:N key=0; for n=1:N key=key+X(n)*exp(-(j*2*pi*(k-1)*(n-1))/N); end Y(k)=key; end %DFT is calculated% Y %DFT is printed% L=length(Y); n=0:1:L-1; figure,plot(n,abs(Y)),title( 'Magnitude Response of DFT' ) figure, plot(n, angle(Y)), title( 'Phase Response of DFT' ) %MAGNITUDE and PHASERESPONSE OF DFT SIGNAL IS PLOTTED% for k=1:N key=0; for n=1:N key=key+Y(n)*exp((j*2*pi*(k-1)*(n-1))/N); end Yinv(k)=key/N; end %IDFT is calculated% Yinv L=length(Y); n=0:1:L-1; figure,plot(n,abs(Yinv)),title( 'Magnitude Response of IDFT' ) figure, plot(n, ang...

Comments
Post a Comment