You are on page 1of 8

LAB-3

Digital Signal Processing Lab


508518

Name

Registration Number

Batch & Section

Instructor’s Name
Lab # 03 Properties of Discrete Time Systems

Objective
This lab allows students to check various properties of discrete systems including linearity, time
invariance, and causality on MATLAB. However, stability of system will be discussed in next
labs.

Pre-Lab:

LINEARITY:
A time-invariant system has the property that a certain input will always give the same output (up
to timing), without regard to when the input was applied to the system.

T[a1 x1 (n) + a2 x2 (n)] = a1T[x1 (n)] + a2T[x2 (n)]

METHODS OF PROOF:
1. Individual inputs are applied and the weighted sum of the outputs is taken.
2. Then the weighted sum of signals input is applied to the system and the two outputs are
checked to see if they are equal.

TIME INVARIANT:
The response of the system to a weighted sum of signals is equal to the corresponding weighted
sum of the responses (outputs) of the system to each of the individual input signals.

In this figure, x(t) and x(t−t0) are passed through the system TI. Because the system TI is time-
invariant, the inputs x(t) and x(t−t0) produce the same output. The only difference is that the output
due to x(t−t0) is shifted by a time t0.
CAUSALITY:
A system is said to be causal, if the output of the system at any time n, (y(n)) depends only on the
present and past inputs and past outputs [x(n),x(n-1)…….y(n-1),…..]
But does not depend on future inputs [x (n+1),x(n+2),…..]

y(n) = F[ x(n),x(n-1),x(n-2)….]

METHODS OF PROOF:
1. If the difference equation is given, the arguments of the output y(n) are compared with the
arguments (time instant) of the input signals. In the case of only present and past inputs,
the system is causal. If future inputs are present then the system is non-causal.
2. If the impulse response is given, then it is checked whether all the values of h(n) for
negative values of n are zero. (i.e.) if h(n)=0, for <0. If this is satisfied, then the system is
causal.

ALGORITHM/PROCEDURE:
 Click on the MATLAB icon on the desktop (or go to start – all programs and click on
MATLAB) to get into the Command Window
 Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
 Write the program in the ‘Edit’ window and save it in ‘M-file’
 Run the program
 Enter the input in the command window
 The result is displayed in the Command window and the graphical output is displayed in
the Figure Window.

In-Lab:

Linearity Example Code


clc;
clear all;
close all;
%Properties of DT Systems(Linearity)
%y(n)=x(n);
x1=input('Enter first input sequence:');
x2=input('Enter second input sequence:');
a=input('Enter scaling constant(a):');
b=input('Enter scaling constant(b):');
subplot(2,2,1);
stem(x1);
xlabel('time');
ylabel('Amplitude');
title('First signal');
subplot(2,2,2);
stem(x2);
xlabel('time');
ylabel('Amplitude');
title('Second signal');
y1=x1;
y2=x2;
rhs=a*y1+b*y2;
x3=a*x1+b*x2;
lhs=x3;
if(lhs==rhs)
display('system is linear');
else
display('system is non-linear');
end;
subplot(2,2,3);
stem(lhs);
xlabel('time');
ylabel('Amplitude');
title('L.H.S');
subplot(2,2,4);
stem(rhs);
xlabel('time');
ylabel('Amplitude');
title('R.H.S');
Linear System 2
Output

Time Invariance Example Code


clc;
clear all;
close all;
%Properties of DT Systems(Time Invariance)
%y(n)=x(n);
x1=input('Enter input sequence x1:');
n0=input('Enter shift:');
x2=[zeros(1,n0),x1];
y1=x1;
y2=x2;
y3=[zeros(1,n0),y1];
if(y2==y3)
display('system is time invariant');
else
display('system is time variant');
end;
subplot(2,2,1);
stem(x1);
xlabel('time');
ylabel('Amplitude');
title('Input signal');
subplot(2,2,2);
stem(x2);
xlabel('time');
ylabel('Amplitude');
title('Signal after shift');
subplot(2,2,3);
stem(y2);
xlabel('time');
ylabel('Amplitude');
title('L.H.S');
subplot(2,2,4);
stem(y3);
xlabel('time');
ylabel('Amplitude');
title('R.H.S');
Time invariant system

Output

Causality Example Code:


clc;
clear all;
close all;
%Properties of DT Systems(Causality)
%y(n)=x(-n);
x1=input('Enter input sequence x1:');
n1=input('Enter lower limit n1:');
n2=input('Enter lower limit n2:');
flag=0;
for n=n1:n2
arg=-n;
if arg<n;
flag=1;
end;
end;
if(flag==1)
display('system is causal');
else
display('system is non-causal');
end;
Non-Causal system

Lab Report Tasks


Task-1: Following equation describes the discrete time system with input x[n] and output y[n]:

System: y[n] = (x[n])2 + B; where B ≠ 0

Write a MATLAB code to check whether the system is linear or not.

Task-2: Following equation describes the discrete time system with input x[n] and output y[n]:

System: y[n] = n*(x[n]);

Write a MATLAB code to check either the system is time invariant or time variant.

You might also like