DSP4
DSP4
AIM: MATLAB Implementation of Discrete Fourier transform (DFT) and Inverse Discrete Fourier
transform (IDFT). FUNCTION: DFT: function[y,ny]=dft(x,N) w=zeros(N,N); for k=0:N-1 n=0:N-1 s=k.*ones(1,N); w(k+1,:)=exp(-j*((2*pi)/N)*(s.*n)); end y=x*w; ny=0:N-1;
IDFT: function[y,ny]=idft(x,N) w=zeros(N,N); for k=0:N-1 n=0:N-1; s=k.*ones(1,N); w(k+1,:)=exp(1i*((2*pi)/N)*(s.*n)); end y=(x*w)./N; ny=0:N-1;
Activity 1. Determine the 8- point DFT of time domain sequence x (n) = [1 1 2 2 3 3]. Also find and plot the corresponding magnitude and phase spectrum.
PROGRAM: x=input('Enter function x'); N=input('Enter N:'); x=[x zeros(1,N-length(x))]; [y,ny]=dft(x,N); stem(ny,abs(y)); xlabel('discrete time') ylabel('amplitude') title('DFT')
GRAPH:
Activity 2. Determine the 8- point IDFT of frequency domain sequence, X (k) = [3, 2+j, 2-j, -3]. Also find and plot the corresponding magnitude and phase spectrum.
Activity 3. Evaluate and plot the circular convolution of the following time domain sequences using DFT and IDFT. Use functions for DFT and IDFT. x (n) = [1, 2 ,-3, 1] and h (n) = [-4, 3, -2, 1, 2]