Discrete Time Systems in Time Domain Task 1: Write MATLAB Code To Find The Response To The Input X (N) of LTI System With Impulse Response
Discrete Time Systems in Time Domain Task 1: Write MATLAB Code To Find The Response To The Input X (N) of LTI System With Impulse Response
Task 1: Write MATLAB code to find the response to the input x(n) of LTI system with impulse response
h(n) for −5 ≤ 𝑛 ≤ 20.
clc;
close all;
clear all;
n=-5:20;
x=ones(1,5);
h=[zeros(1,7) ones(1,6) zeros(1,3) ones(1,6)];
y=conv(x,h);
stem(n,y);
xlabel('sampels')
ylabel('magnitude')
title('Output of LTI system')
4.5
3.5
3
magnitude
2.5
1.5
0.5
0
-5 0 5 10 15 20
sampels
We convolved input signal and system impulse response to find output. Conv command is used
to convolve the two signals to find output.
Task 2: The output of LTI system with an impulse response h(n) is multiplied by a unit step function u(n)
to yield the output of the overall system as shown in Fig 1. Write MATLAB code for output of the overall
system for the input shown in Fig.2 for −20 ≤ 𝑛 ≤ 20
clc;
close all;
clear all;
n=-20:20;
n1=-17:18;
x=[6 5 4 3 2 1];
u1=[zeros(1,7) ones(1, 29)];
h=(0.25.^n1).*u1;
y1=conv(x,h);
u=[zeros(1,20) ones(1,21)];
y=y1.*u;
stem(n,y);
xlabel('sampels')
ylabel('magnitude')
title('Overall Output of LTI system')
Overall Output of LTI system
30
25
20
magnitude
15
10
0
-20 -15 -10 -5 0 5 10 15 20
sampels
we convolved input signal and system response and then multiply by unit step to find overall
output.