NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
EE-3404: Digital Signal Processing Lab
Session: Spring-2023
EXPERIMENT NO 6:
Open Ended Lab-1
Student Name & Reg No : Waleed Yousaf (F21603042)
Date of Experiment : 3-4-2024
Affective Domain Rubric Based Assessment
Levels of Achievement
Unacceptable Just acceptable Basic Good Excellent Marks
(1) (2) (3) (4) (5)
I. Engagement
II. Attitude and Goal Setting
Psychomotor Domain Rubric Based Assessment
Levels of Achievement
Unacceptable Just acceptable Basic Good Excellent Marks
(1) (2) (3) (4) (5)
1. Approach towards problem
II. Implementation and Results
Lab Report Rubric Based Assessment
Levels of Achievement
Unacceptable Just acceptable Basic Good Excellent Marks
(1) (2) (3) (4) (5)
I. Organization/Structure
II. Results and Conclusion
Submitted to: L.E Sidra Ashraf
Instructor’s Signature: ________________________________________________________
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
Open Ended Lab-I
Problem 1: [CLO-2, PLO3]
For the signal
−2 n
x [ n ] =n e 1 ≤ n≤ 7
Perform the following operations:
a) Extract value of x atn=2.
Solution:
function abc()
n = 1:7;
x = n.*(exp(-2.*n));
subplot(2,1,1)
stem(n, x);
title('X[n]')
subplot(2,1,2)
stem(n,x);
title('x[n] at n=2')
end
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
b) Find and plot: h(n)= { 2 x (n),∧n<3
x (n) , Otherwise
Solution:
function abc()
n=1:7;
n1=input('Enter Value of n:');
x= n.*(exp(-2.*n));
if n1<3
stem(n,2*x)
title('2x[n]')
xlabel('n')
ylabel('Amplitude')
else
stem(n,x)
title('x[n]')
xlabel('n')
ylabel('Amplitude')
end
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
c) Implement sequence of problem b with a shift of 2 to get h '(n) and plot it.
Solution:
function abc()
n=1:7;
n1=input('Enter Value of n:');
x= n.*(exp(-2.*n));
if n1<3
stem(n-2,2*x)
title('2x[n] left Shifted')
xlabel('n')
ylabel('Amplitude')
else
stem(n-2,x)
title('x[n] left Shifed')
xlabel('n')
ylabel('Amplitude')
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
end
d) Using x (n) and h '(n), perform the convolution operation.
Solution:
function abc()
n=1:7;
x1= (n-2).*(exp(-2.*(n-2)));
x= n.*(exp(-2.*n));
subplot(3,1,1)
stem(n,x);
title('X[n]')
xlabel('n')
ylabel('X[n]')
subplot(3,1,2)
a=stem(n-2,x);
title('h-dash-[n]')
xlabel('n')
ylabel('h[n]')
subplot(3,1,3)
a=conv(x,x1);
stem(a)
title('X[n]*h-dash-[n](Convoluted Signal')
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
xlabel('n')
ylabel('Amplitude')
end
e) Using x (n) and h(n), perform the convolution operation.
Solution:
function abc()
n=1:7;
n1=input('Enter Value of n:');
x= n.*(exp(-2.*n));
subplot(3,1,1)
if n1<3
a=2*x;
stem(n,a)
title('h[n]')
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
xlabel('n')
ylabel('Amplitude')
else
a=x;
stem(n,a)
title('h[n]')
xlabel('n')
ylabel('Amplitude')
end
subplot(3,1,2)
stem(n,x)
title('x[n]')
xlabel('n')
ylabel('Amplitude')
subplot(3,1,3)
a=conv(x,a)
stem(a)
title('Covoluted Signal=X[n]*h[n]')
xlabel('n')
ylabel('Amplitude')
end
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
Problem 2: [CLO-2, PLO3]
Perform Convolution of the following sequences using for loop or matrix method by making
Matlab Function file and plot the input, impulse response and output in one figure:
x[n] = [-1 4 -3 -2 1 0 2], n=[-2:4] h[n] = [1 1 1], n= [-1 0 1]
Solution:
function abc()
n1=-2:4;
x=[-1 4 -3 -2 1 0 2];
n2=[-1:1];
h=[1 1 1];
subplot(3,1,1)
stem(n1,x)
title('x[n]')
xlabel('n')
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
ylabel('Amplitude')
subplot(3,1,2)
stem(n2,h)
title('h[n]')
xlabel('n')
ylabel('Amplitude')
subplot(3,1,3)
a=conv(x,h)
stem(a)
title('x[n]*h[n] Convoluted Signal')
xlabel('n')
ylabel('Amplitude')
end
Problem 3: [CLO-1, PLO5]
Produce the input signal x[n] by adding two input signals x 1[n] and x2[n] and then convolve
with h[n] to find the response of the system and plot the output.
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
Note:
x1[n], x2[n], and h[n] will be provided by user (along with time axis).
Solution:
function abc()
n=1:4;
x1=input('Signal Amplitdue(x1[n]) as Row vector:');
x2=input('Signal Amplitdue(x2[n]as Row vector:');
h=input('Signal Amplitdue (h[n]) as Row vector:');
x3=x1+x2;
subplot(3,1,1)
stem(n,x3)
title('x[n]=x1+x2x[n]')
xlabel('n')
ylabel('Amplitude')
subplot(3,1,2)
stem(n,h)
title('h[n]')
xlabel('n')
ylabel('Amplitude')
subplot(3,1,3)
a=conv(x3,h)
stem(a)
title('x[n]*h[n] Convoluted Signal')
xlabel('n')
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING
ylabel('Amplitude')
end
Note:
Make proper lab report by stating the objective, procedure, and explanation of output results
with conclusion.
Comments:
NATIONAL UNIVERSITY OF TECHNOLOGY
(NUTECH)
DEPARTMENT OF ELECTRICAL
ENGINEERING