Professional Documents
Culture Documents
Introduction
Mathematically, a discrete-time system is described as an operator T[.] that takes a sequence
x(n) called excitation and transforms it into another sequence y(n) (called response). Discrete
time systems can be classified into two categories i) LTI systems ii) NON-LTI systems. A
discrete system T[.] is a linear operator L[.] if and only if L[.] satisfies the principle of
superposition, namely
L[a1x1(n) + a2x2(n)] = a1L[x1(n)] + a2Lx2(n)] and
A discrete system is time-invariant if
Shifting the input only causes the same shift in the output
A system is said to be bounded-input bounded-output(BIBO) stable if every bounded input
produces a bounded output.
An LTI system is BIBO stable if and only if its impulse response is absolutely summable.
A system is said to be causal if the ouput at index n0 depends only on the input up to and
including the index no; that is output does not depend on the future values of the input. An
LTI system is causal if and only if the impulse response is
clear all,
close all
n = 0:40;
a = 2; b = -3;
x1 = cos(2*pi*0.1*n);
x2 = cos(2*pi*0.4*n);
x = a*x1 + b*x2;
num = [2.2403 2.4908 2.2403];
den = [1 -0.4 0.75];
ic = [0 0 ]; % Set zero initial conditions
y1 = filter(num,den,x1,ic); % Compute the output y1[n]
y2 = filter(num,den,x2,ic); % Compute the output y2[n]
y = filter(num,den,x,ic); % Compute the output y[n]
yt = a*y1 + b*y2;
Output Due to Weighted Input
50
Amplitude
d = y - yt; % Compute the difference output d[n] % Plot the outputs and the
difference signal subplot (3,1,1)
0
30
35
40
30
35
40
Amplitude
Amplitude
subplot(3,1,1);
stem(n -50
,y);
0
5
10
15
20
25
ylabel('Amplitude');
title('Output Due to Weighted Input');
Weighted Output
subplot(3,1,2);
50
stem(n,yt);
ylabel('Amplitude');
0
title('Weighted
Output');
subplot(3,1,3);
stem(n,d);
-50
0 index5n');
10
15
20
25
xlabel('Time
ylabel('Amplitude');
Difference Signal
axis ([0 40
30 0 30])
title('Difference Signal');
20
Question
10 1: Run above program and compare y[n] obtained with weighted input with
yt[n] obtained
by combining the two outputs y 1[n] and y2[n] with the same weights. Are
0
0
5
10
15
20
25
30
35
40
these two sequences equal? Is this system
Timelinear?
index n
yes! linear.
2. Time-Invariant and Time-Varying Systems
We next investigate the time-invariance property. Following Program simulates
following difference equation
y[n]0.4 y[n1]+0.75 y[n2] = 2.2403 x[n]+2.4908 x[n1]+2.2403 x[n2]
Two input sequences x[n] and x[n - D], are generated and corresponding
output sequences y1[n], y2[n] are plotted.
Amplitude
2
Question 22: Use filter command to get the impulse response of the same system.
% Compute the impulse response y
1
clf;
1
n=0:40;
N = length(n);
x=[1,zeros(1,N-1)];
0
num = [2.2403
0 2.4908 2.2403];
den = [1 -0.4 0.75];
y = filter(num,den,x);
-1
yd = impz(num,den,N);
-1
% Plot the impulse response
stem(n,y) -2
figure (2) -2
stem(n,yd)
xlabel('Time index n')
-3
ylabel('Amplitude')
5
10
15
20
25
30
35
-30
title('Impulse
0 Response')
5
10
15
20
25
30
35
Time index n
Question 3: Write a MATLAB program to generate and plot the step response of a
causal LTI system used in the previous Question.
% Compute the impulse response y
clf;
n=0:40;
N = length(n);
x=ones(1, N);
num = [2.2403 2.4908 2.2403];
den = [1 -0.4 0.75];
y = filter(num,den,x);
% Plot the impulse response
stem(n,y)
40
40
3
2
1
xlabel('Time index n')
ylabel('Amplitude')
title('Impulse
Response')
0
0
5
10
15
20
25
Time index n
30
35
40
Amplitude
2
h = impz(num,den,N+1);
parsum = 0;
for k = 1:N+1;
parsum =1 parsum + abs(h(k));
if abs(h(k)) < 10^(-6),
break,
end
0
end
% Plot the impulse response
n = 0:N;
stem(n,h)
-1
xlabel('Time index n');
ylabel('Amplitude');
% Print the value of abs(h(k))
-2
disp('Value
=');
disp(abs(h(k)))
OUTPUT:-3
Value = 0
9.1752e-007
50
100
150
200
250
300
Time index n
350
400
450
500
disp('Value =');
disp(abs(h(k)))
OUTPUT:
Value =
0.1073
SO UNSTABLE.
5 Convolution in MATLAB
MATLAB does provide a built-in function called conv that computes the convolution
between two finite duration sequences. The conv function assumes that the two
sequences begin at n=0.
>> y = conv(x, h);
However The conv function neither provides nor accepts any timing information. What is
needed is a beginning point and an end point of y(n). So we define another function conv_m.
The following example will clear its usage.
% x(n)=[3,11,7,0,-1,4,2]; nx = [-3:3]
% h(n)=[2,3,0,-5,2,1]; nh = [-1:4]
% y(n)=conv(x,h)
x = [3, 11, 7, 0, -1, 4, 2];
nx = [-3: 3];
h = [2, 3, 0, -5, 2, 1];
nh = [-1: 4];
[y,ny] = conv_m(x,nx,h,nh)
Stem(y,ny)