KATHMANDU UNIVERSITY

Communication Laboratory
DSP_LAB 1:Discrete Fourier Transform
Shravan Kumar Luitel (32015) 4/6/2011

Submitted To : Ansu Man Singh

Exercises: 5 & 6 »Write a code to plot a sinusoidal sequence of a sinusoidal signal of 50Hz sampled at 250 Hz of 50 samples. Plot the frequency response of the above sequence with the help of FFT , inbuilt MATLAB function . Code :
%% generating a sinusoidal sequence of a sinusoidal signal of 50Hz sampled %% at 250Hz of 50 samples. n=1:50; x5=cos(2*pi/5*n); subplot(3,1,1); stem (x5,'filled','k'); title('Sinusoidal Sequence of Period 50 Samples '); %% generating the frequency response of the above sequence with the help of fft X=fft(x5); subplot(3,1,2); plot(abs(X),'k'); ylabel('Magnitude'); xlabel('Samples'); title('Magnitude Response'); subplot(3,1,3); plot(angle(X),'k'); ylabel('Angle'); xlabel('Samples'); title('Phase Response');

Figure:

7, 8 & 9 »Create a sinusoidal sequence of period 12 samples . Then create Wn matrix of 12 rows and 12 columns . Multiply the sequence by Wn matrix to obtain the frequency spectrum of the sequence . Plot magnitude and phase part of the spectrum . Code:
% Plotting a Sinusoidal sequence(x7) of period 12 samples n=1:12; x7=cos(2*pi/5*n); subplot(3,1,1); stem(n,x7,'k','filled'); title('Sinusoidal Sequence of Period 12 samples'); % Creating Wn matrix of 12 rows and 12 columns j=0:11; k=0; while k<=11 Wn(j+1,k+1)=exp(-i*2*pi/12*j*k); k=k+1; end % Multiplying x7 by Wn to obtain the frequency spectrum of x7 X=x7*Wn; % Plotting magnitude and Phase part of the spectrum subplot(3,1,2); plot(abs(X),'k'); title('Magnitude Response'); xlabel('Samples'); ylabel('Magnitude'); subplot(3,1,3); plot(angle(X),'k'); title('Phase Response'); xlabel('Samples'); ylabel('Angle');

Figure:

10 »Find the 12 point DFT using FFT inbuilt function and compare the result with the spectrum of question 9. Code :
% Plotting a Sinusoidal sequence(x7) of period 12 samples n=1:12; x7=cos(2*pi/5*n); subplot(3,1,1); stem(n,x7,'k','filled'); title('Sinusoidal Sequence of Period 12 samples'); % Observing the Spectrum using FFT X=fft(x7); subplot(3,1,2); plot(abs(X),'k'); title('Magnitude Response'); xlabel('Samples'); ylabel('Magnitude'); subplot(3,1,3); plot(angle(X),'k'); title('Phase Response'); xlabel('Samples'); ylabel('Angle');

Figure:

Conclusion : The spectra given by W martix and FFT inbuilt function of Matlab are identical .

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.