You are on page 1of 6

Sessional-2

Student Name: Wajahat Murtaza - FA19-EPE-125

Registration Number: FA19-EPE-125


Class/Section: EPE-4C
Semester: Fourth

Lab Engineer Name: Sir Izhar


Corse Teacher Name: Dr. Noman Tareen
Submission Date: 23 May 2021

Marks:

A P C
Sessional 2-
Ques 1:
Find the output of Discrete Time System having input and impulse response given;

X[n]=u[n] and h[n]=u[n]-u[n-10]


Code:
Function:
function us = unit_step(t)

us = 0.*(t<0)+1.*(t>=0)

end

Main File:
clc;
clear all;
close all;

n = -20:20;

% X is a unit step function


X = unit_step(n);

figure;
stem(n, X,'r');
xlabel('n');
ylabel('X(n)');
title('Input: X(n)');

% h is impulse response
h = unit_step(n)-unit_step(n-10);
figure;
stem(n, h,'r');
xlabel('n');
ylabel('h(n)');
title('Impulse Response: h(n)');

Y=conv(h, X, 'same');
figure;
stem(n, Y,'b');
xlabel('n');
ylabel('Y(n)');
title('Output: Y(n)');

Output:
Figure 1:
Figure 2:
Figure 3:
Code Picture:

THE END

You might also like