You are on page 1of 9

DIGITAL SIGNAL PROCESSING

LAB NO. 062

Submitted By:
Name: HAIDER ALI MUNIR
ID No: 170887
Class/Sec: BEEP V-B
Submitted To: MAM ANUM ZULQARNAIN
Instructor’s Remarks:

Submission In Late in Working Days


Time: Time 0 1 2 3 4 5

Marks: Total Marks Obtained Marks

Additional Remarks:
______________________________________________________

Instructor’sSignature:_____________
Objective:- The goal of this laboratory is to gain familiarity with the
frequency response of the signals and systems.
Program P7_1 can be used to evaluate and plot the DTFT
MATLAB CODE:
w = -4*pi:8*pi/511:4*pi;
num = [2 1];den = [1 -0.6];
h = freqz(num, den, w);
subplot(2,1,1)
plot(w/pi,real(h))
grid on
hold on
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h))
grid on
hold on
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));
grid on
hold on
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));
grid on
hold on
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase, radians' );
plot:
Question 7.1:
Pause Command:

Pause (MATLAB Function Reference) pause, by itself, causes M-files to stop and wait for you to press


any key before continuing. pause(n) pauses execution for n seconds before continuing. pause on allows
subsequent pause commands to pause execution.

Question 7.2:
 Following is the Real and imaginary part of the function that are displayed speratly .

 Following is the magnitude and phase angle to be displayed by use of the pause command.

YES,the dtft is a periodic signal,and the period is T=2w/pi-w/pi or ω = -4π:8π/511:4π


Question 7.3:
Matlab Code:

w = 0:pi/511:2*pi;
num = [0.7 -0.5 0.3 1];den = [1 0.3 -0.5 0.7];
h = freqz(num, den, w);
subplot(2,1,1)
plot(w/pi,real(h))
grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h))
grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,2)
plot(w/pi,abs(h));
grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));
grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase, radians' );
Result:

 Real and imaginary part of the function to be extracted separately.

 Following is the magnitude and phase angle to be displayed speratly by the use of the pause
command.
Observation:

We have observed that this DTFT is a repeating signal therefore, it is a periodic wave with the
period under ω, ω = 0 ≤ ω ≤ π .

Question 7.4:
Matlab code:

clf;
w = -pi:2*pi/255:pi; wo = 0.6*pi; D = 15;
num = [1 2 3 4 5 6 7 8 9];
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1))
grid on
hold on
title('The Magnitude Spectrum of our Original Sequence')
subplot(2,2,2)
plot(w/pi,abs(h2))
grid on
hold on
title('The Magnitude Spectrum of our Time-Shifted Sequence')
subplot(2,2,3)
plot(w/pi,angle(h1))
grid on
hold on
title('The Phase Spectrum of our Original Sequence')
subplot(2,2,4)
plot(w/pi,angle(h2))
grid on
hold on
title(' The Phase Spectrum of our Time-Shifted Sequence')
plot:

1.1.1. Question no 7.5:


Matlab code:

clf;
w = -pi:2*pi/255:pi; wo = 0.6*pi; D = 15;
num = [1 2 3 4 5 6 7 8 9];
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1))
grid on
hold on
title('The Magnitude Spectrum of our Original Sequence')
subplot(2,2,2)
plot(w/pi,abs(h2))
grid on
hold on
title('The Magnitude Spectrum of our Time-Shifted Sequence')
subplot(2,2,3)
plot(w/pi,angle(h1))
grid on
hold on
title('The Phase Spectrum of our Original Sequence')
subplot(2,2,4)
plot(w/pi,angle(h2))
grid on
hold on
title(' The Phase Spectrum of our Time-Shifted Sequence')
plot:

Code 2:(in this task we have just change our value of wo and D)

w = -pi:2*pi/255:pi; wo = 6*pi; D = 50;


num = [1 2 3 4 5 6 7 8 9];
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1))
grid on
hold on

title(' The graph of the Magnitude Spectrum of our Original Sequence')


subplot(2,2,2)
plot(w/pi,abs(h2))
grid on
hold on

title('The graph ofMagnitude Spectrum of our Time-Shifted Sequence')


subplot(2,2,3)
plot(w/pi,angle(h1))
grid on
hold on
title('The graph of Phase Spectrum of our Original Sequence')
subplot(2,2,4)
plot(w/pi,angle(h2))
grid on
hold on
title('The graph of Phase Spectrum of Time-Shifted Sequence')

plot2:
2. Learning Outcomes:
The learning outcomes of our lab are as follows:

 The introduction to the time shifting properties of signal in matlab.


 The introduction with the different sequences of varying lengths and
different time- shifts.

You might also like