DSP Lab#05
DSP Lab#05
Lab Manual No 05
Instructor:
Engr. M. Tahir Saeed
Objectives:-
In this lab we will study the linearity and nonlinearity of the system using MATLAB. The
objectives of this lab are:
1) To study and check the linearity and non linearity of the system
2) To study the Time invariant and time varying system
Software:
MATLAB 2013
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
Shifting the input only causes the same shift in the output
An LTI system is BIBO stable if and only if its impulse response is absolutelysummable.
A system is said to be causal if the output at index n0 depends only on the input up to and
including the index no; that is output does not depend on thefuture 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];
yt = a*y1 + b*y2;
subplot (3,1,1)
stem(n ,y);
ylabel('Amplitude');
stem(n ,yt);
ylabel('Amplitude');
title('Weighted Output');
subplot(3,1,3)
stem(n,d);
Question 1: Run above program and compare y[n] obtained with weighted input with yt[n]
obtained by combining the two outputs y1[n] and y2[n] with the same weights. Are these
two sequences equal? Is this system linear?
Exercise 1: Consider another system described by y[n] = x[n] x[n − 1]. Modify given
program to compute the output sequences y1[n], y2[n], and y[n] of the above system.
Compare y[n] with yt[n]. Are these two sequences equal? Is this system linear?
Two input sequences x[n] and x[n - D], are generated and correspondingoutput
sequences y1[n], y2[n] are plotted.
x = a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n);
xd = [zeros(1,D) x];
num = [2.2403 2.4908 2.2403];
den = [1 -0.4 0.75];
ic = [0 0];% Set initial conditions
% Compute the output y[n]
y = filter(num, den, x, ic);
% Compute the output yd[n]
yd = filter(num, den, xd, ic);% Compute the difference output d[n]
subplot(3,1,1)
stem(n,y);
ylabel('mplitude');
title('Output y[n]');
grid;
subplot(3,1,2)
stem(n,yd(1:41));
ylabel('Amplitude');
subplot(3,1,3) stem(n,d);
xlabel('Time index n');
ylabel('Amplitude'); title('Difference
Signal');grid;
Modify Program to simulate the above system and determine whether thissystem is
time-invariant or not.
Lab Task: Perform Exercise 1 and Exercise 2 and prepare a lab report on it!