Birla Institute of Technology Mesra Jaipur Digital Signal Processing Kushagra gupta BTECH/25164/19 EEE 5th sem Q: Object: Compute N point DFT & IDFT of the length N sequence using MATLAB 2.a DFT 2.b IDFT Solution: Code of Matlab:%DFT and IDFT clc; clear; close; x=input('Enter the Input Seq'); N=length(x); disp(N); y=zeros(1,N); for k=0:N-1 for n=0:N-1 y(k+1)=y(k+1)+x(n+1)*exp((-2*i*pi*k*n)/N); end end magnitude=abs(y); subplot(3,2,1); stem(magnitude); xlabel('frequency'); ylabel('Magnitude'); title('magnitude part '); z=phase(y); subplot(3,2,2); stem(z); xlabel('Frequency'); ylabel('Phase'); title('Phase part'); N=length(y); m=zeros(1,N); for n=0:N-1 for k=0:N-1 m(n+1)=m(n+1)+((1/N)*(y(k+1)*exp(((i)*2*pi*k*n)/N))); end end % IDFT disp('m=') disp(m) subplot(3,2,3); stem(m); xlabel('frequency'); ylabel('Magnitude'); title('magnitude part of IDFT'); n=phase(m); subplot(3,2,4); stem(n); xlabel('Frequency'); ylabel('Phase'); title('Phase part of IDFT');