eee 413 digital signal processing lab assignment 5

advertisement
EEE 413 DIGITAL SIGNAL PROCESSING
LAB ASSIGNMENT 5
Objective: Discrete Fourier Transform (DFT) is used to determine frequency content of
periodic signals. In this lab, you will learn about how to determine the frequency content of
any periodic time domain signal. Follow the steps given below.
1. Matlab Code
% EEE 413 Digital Signal Processing Laboratory
% MATLAB simulations V : Discrete Fourier Transform
clear all ;clc
%Example
%Use the following code to create the input signal x(n)
clear all;
x=[1:1:32]; %Create a square wave
xsig(1:16)=1;
xsig(16:32)=-1;
figure(1); %Plot the waveform
plot(xsig);
axis([1 32 -2 2]);
%Take DFT and plot first four harmonics
fftResCompl=fft(xsig);
fftMagn=abs(fftResCompl);
fftAngle=angle(fftResCompl);
figure(2);
for i=1:4
xharmonic(i,1:32)=fftMagn(i+1)*sin(2*pi*i*x/32+fftAngle(i+1));
subplot(4,1,i);
plot(xharmonic(i,:));
end
title('1st through 4th');
figure(3);
for i=1:4
xharmonic(i+4,1:32)=fftMagn(i+5)*sin(2*pi*(i+4)*x/32+fftAngle(i+5));
subplot(4,1,i);
plot(xharmonic(i+4,:));
end
title('5th through 8th');
You are given above the code for plotting first eight harmonics. Find and plot the output for
harmonics 9 through 28 meaning you are to generate five more plots. Comment on why the
plots after 16th harmonic look like harmonics 16 and lower. Also find the frequency of each
harmonic if the sampling frequency is 1600Hz.
2. Assignment (Due on 01-11-2015)
a. Define a triangular input waveform using the following code sequence:
x=[0.1:0.1:128];
xsig=sawtooth(x,0.5);
b. Apply Discrete Fourier Transform to determine the sinusoids that make up the
triangular waveform. Plot the first eight harmonics. Hint: Fundamental period has 64
samples .
c. If the sampling rate is 3200 Hz, what are the frequencies of first four harmonics?
Download