Chapter 2 Discrete Systems
Chapter 2 Discrete Systems
2.5
1.5
s(n)
0.5
0
-20 0 20 40 60 80 100 120
Chapter 2
n
P R E P A R E D B Y : B e w n e t G e t a c h ew
DISCRETE-TIME SIGNALS
Signals are broadly classified into analog and discrete signals. An analog signal
will be denoted by x,(t), in which the variable t can represent any
physical quantity, but we will assume that it represents time in seconds.
A discrete signal will be denoted by x (n), in which the variable n is integer
valued and represents discrete instances in time. Therefore it is also called a
discrete time signal, which is a number sequence and will be denoted by
one of the following notations:
1. sequence
x(n) = {2,1, -1 ,0, 1,4,3,7}
2. Tabular
X(n) 2 1 -1 0 1 4 3 7
n -3 -2 -1 0 1 2 3 4
3. Graphical
10
2
x(n)
-2
-4
-6
-8
-10
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
4. MATLAB representation
n=[-3:4]
x=[2, 1, -1, 0, 1, 4, 3, 7]
stem(n,x)
xlabel('n');ylabel('x(n)')
axis([-5,5,-10,10])
grid
Elementary sequences
We use several elementary sequences in digital signal processing for analysis
purposes.
1. Unit sample sequence:
MATLAB
2
n=[-4:4]
1
x=[0,0, 0, 0, 1, 0, 0, 0, 0]
stem(n,x)
6(n
0
xlabel('n');ylabel(' d(n')
axis([-5,5,-3,3]) -1
grid
-2
-3
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
1. Unit sample sequence:
n=[-10:10];
n1=[-10:-1];
n2=[0];
n3=[1:10];
x1=zeros(1,length(n1));
x2=ones(1,length(n2));
x3=zeros(1,length(n3));
x=[x1,x2,x3];
stem(n,x)
xlabel('n');
ylabel(' x(n)')
axis([-10,10,-3,3])
grid
2. Unit step sequence:
MATLAB
2
n=[-6:6]
x=[0,0,0,0, 0, 0, 1, 1, 1, 1, 1,1,1] 1
stem(n,x)
u(n
0
xlabel('n');ylabel('u(n')
axis([-5,5,-3,3]) -1
grid -2
-3
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
2. Unit step sequence:
n=[-10:10];
n1=[-10:-1];
n2=[0:10];
x1=zeros(1,length(n1));
x2=ones(1,length(n2));
x=[x1,x2];
stem(n,x)
xlabel('n');
ylabel(' x(n')
axis([-10,10,-3,3])
grid
3. Real-valued exponential sequence:
n=[-5:10]
2
x=(0.9).^n
stem(n,x) 1
xlabel('n');ylabel('x(n') x(n
0
axis([-10,15,-3,3])
grid -1
-2
-3
-10 -5 0 5 10 15
n
Case (ii) a>1 (growing exponential)
X(n)=(2)n 0<n<10
n=[-5:3] 10
x=(2).^n
8
stem(n,x)
xlabel('n');ylabel('x(n') 6
axis([-5,5,-3,10])
4
grid x(n
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
4. Sinusoidal sequence:
n=[-10:10] 2
x=2*cos((0.1*pi*n)+(pi/3))
stem(n,x) 1
xlabel('n');ylabel('x(n')
axis([-10,10,-3,3])
x(n
0
grid
-1
-2
-3
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
Example 2: x(n)= 2cos(2n) 0<n<10 non periodic sinusoidal
sequence
n=[-10:10] 3
x=2*cos(2*n)
stem(n,x) 2
xlabel('n');ylabel('x(n') 1
axis([-10,10,-3,3])
grid
x(n
0
Note -1
As we can see from the
above examples a discrete -2
sinusoidal signal can be
periodic or non periodic. -3
-10 -8 -6 -4 -2 0 2 4 6 8 10
But all continuous time n
sinusoidal signal are
periodic
OPERATIONS ON DT DIGNALS
1. Signal addition:
n=[-3:1]
x1=[2, -1, 0, 4, -0.5]
x2=[-1, 0, 3, 1.5 ,2]
x3=x1+x2
subplot(3,1,1),stem(n,x1),xlabel('n');ylabel('x1(n'),grid,axis([-5,5,-3,5])
subplot(3,1,2),stem(n,x2),xlabel('n');ylabel('x2(n'),grid,axis([-5,5,-3,5])
subplot(3,1,3),stem(n,x3),xlabel('n');ylabel('x1(n)+x2(n)'),grid,axis([-
5,5,-3,7])
4
2
x1(n
0
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
4
2
x2(n
0
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
6
x1(n)+x2(n)
4
2
0
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
Example 2 Add discrete time signals x1(n) + x2(n)
x1(n)= 2cos(0.1πn)
x2(n)=sin(0.5πn)
n=[-10:10]
x1=2*cos(0.1*pi*n)
x2=sin(0.5*pi*n)
x3=x1+x2
subplot(3,1,1),stem(n,x1),xlabel('n');ylabel('x1(n'),grid,axis([-10,10,-3,5])
subplot(3,1,2),stem(n,x2),xlabel('n');ylabel('x2(n'),grid,axis([-10,10,-3,5])
subplot(3,1,3),stem(n,x3),xlabel('n');ylabel('x1(n)+x2(n)'),grid,axis([-10,10,-3,7])
4
2
x1(n
0
-2
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
4
2
x2(n
0
-2
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
6
x1(n)+x2(n)
4
2
0
-2
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
2. Signal multiplication:
n=[-3:1]
x1=[2, -1, 0, 4, -0.5]
x2=[-1, 0, 3, 1.5, 2]
x3=x1.*x2
subplot(3,1,1),stem(n,x1),xlabel('n');ylabel('x1(n'),grid,axis([-5,5,-3,5])
subplot(3,1,2),stem(n,x2),xlabel('n');ylabel('x2(n'),grid,axis([-5,5,-3,5])
subplot(3,1,3),stem(n,x3),xlabel('n');ylabel('x1(n).x2(n)'),grid,axis([-5,5,-3,7])
4
x1(n 2
0
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
4
2
x2(n
0
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
6
x1(n).x2(n)
4
2
0
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
3. Scaling:
In this operation each sample is multiplied by a scalar a.
{x(n)} = {ax(n)}
Example 1 Determine and plot x2(n) =ax1(n) where a=2.
x1(n)= {2,-1,0,4,-0.5}
n=[-3:6]
x1=[2, -1, 0, 4, -0.5, 1, 3 ,-2, 1.5, -0.25]
x2=2*x1
subplot(2,1,1),stem(n,x1),xlabel('n');ylabel('x1(n'),grid,axis([-5,5,-5,10])
subplot(2,1,2),stem(n,x2),xlabel('n');ylabel('x2(n'),grid,axis([-5,5,-
5,10])
10
5
x1(n
-5
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
10
5
x2(n
-5
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
Shifting: In this operation each sample of x(n) is shifted by an amount k
to obtain a shifted sequence y(n).
y(n) = {x(n - k)}
y(n) = {x(n - k)} time delay (shifting the signal towards the right)
n=[-3:3]
x=[2, -1 ,0, 4, -0.5, 1, 3 ]
m=n+2
subplot(2,1,1),stem(n,x),xlabel('n');ylabel('x(n)’),grid,axis([-10,10,-5,8])
subplot(2,1,2),stem(m,x),xlabel('n');ylabel(‘y(n)=x(n-2)'),grid,axis([-10,10,-
5,8])
8
6
4
2
x(n)
0
-2
-4
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
8
6
4
y(n)=x(n-2)
2
0
-2
-4
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
Example 2 Determine and plot y(n) =x(n+2)
x(n)= {2,-1,0,4,-0.5}
n=[-3:3]
x=[2 -1 0 4 -0.5 1 3 ]
m=n-2
subplot(2,1,1),stem(n,x),xlabel('n');ylabel('x(n)’),grid,axis([-5,5,-5,8])
subplot(2,1,2),stem(m,x),xlabel('n');ylabel(‘y(n)=x(n+2)'),grid,axis([-5,5,-5,8])
y(n) = {x(n + k)} time advance (shifting the signal towards the left)
8
6
4
x(n)
2
0
-2
-4
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
8
6
y(n)=x(n+2)
4
2
0
-2
-4
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
Lab work(2.5 Marks)
Given
x[n]={0.5, 2, -1.5, 2.5, 4, 3, -2, 3.5, 2, 0.5}
Write a MATLAB program to generate and sketch the following signals on the
same figure
a) x[n]
b) x[n-3]
c) x[n+3]
Folding: In this operation each sample of x(n) is flipped around
n = 0 to obtain a folded sequence y(n).
y(n) = {x(-n)}
Example 1 Determine and plot y(n) =x(-n)
x(n)= {2,-1,0,4,-0.5, 1, 3}
n=[-3:3]
x=[2 ,-1, 0, 4, -0.5, 1, 3 ]
m=-n
subplot(2,1,1),stem(n,x),xlabel('n');ylabel('x(n)’),grid,axis([-5,5,-5,8])
subplot(2,1,2),stem(m,x),xlabel('n');ylabel(‘y(n)=x(-n)'),grid,axis([-5,5,-5,8])
2
0
-2
-4
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
8
6
4
y(n)=x(-n)
2
0
-2
-4
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
EXAMPLE 1 Generate and plot each of the following sequences over the
indicated interval.
Solution Example 3
n = [-10:10];
alpha = -0.1+0.3j;
x = exp(alpha*n);
subplot (2 ,2,1) ; stem(n,real(x)) ;title( 'real part ') ;
subplot (2,2,2) ; stem(n, imag(x)) ; title('imaginary part' ) ;
subplot (2,2,3) ; stem(n, abs (x)) ; title ('magnitude part ' ) ;
subplot (2,2,4) ; stem(n, (180/pi) *angle (x)) ; title ( 'phase part' ) ;
real part imaginary part
2 1
1
0
0
-1
-1
-2
-3 -2
-10 -5 0 5 10 -10 -5 0 5 10
n n
magnitude part phase part
3 200
100
2
0
1
-100
0 -200
-10 -5 0 5 10 -10 -5 0 5 10
n n
There are several important results in discrete time signal theory. We will
discuss some that are useful in digital signal processing
1. Unit sample synthesis
Any arbitrary sequence x(n) can be synthesized as a weighted sum of
delayed and scaled unit sample sequences, such as
xe (-n) = xe (n)
Similarly, a real-valued sequence x o(n) is called odd (antisymmetric) if
xo(-n) = -x o(n)
Then any arbitrary real-valued sequence x(n) can be decomposed into its
even and odd components
x(n) = x e(n) + x o(n)
where the even and odd parts are given by
EXAMPLE 1 Let x(n) = u(n) - u(n - 10). Decompose x(n) into even and
odd components.
3. Signal energy:
The energy of a sequence x(n) is given by
4. Signal power:
The average power of a periodic sequence with fundamental period N is given by
Ex-1 Calculate the energy of the following DT signal
x[n]={-1, 0, 2, 3, 1}
x(n) y(n)
T[.]
x3(n)=ax1(n)+bx2(n)
DS y3(n)
Time invariant system is also called shift invariance because shifting the
Input by a value of k causes only shift of the output by the same amount.
Linear time-invariant (LTI) system
A linear system in which an input-output pair, x(n) and y(n), is
invariant to a shift n in time is called a linear time invariant system.
3. Stability
This is a very important concept in linear system theory. The primary
reason for considering stability is to avoid building harmful systems or
to avoid burnout or saturation in the system operation. 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.
4. Causality
This important concept is necessary to make sure that systems can
be built. A system is said to be causal if the output at index
no depends only on the input up to and including the index no; that
is, the output does not depend on the future values of the input. An
LTI system is causal if and only if the impulse response
h(n) =o, n < O
Such a sequence is termed a causal sequence. In signal processing,
unless otherwise stated, we will always assume that the system is
causal.
CONVOLUTION
δ(n) h(n)
LTI
DS
δ(n-k) h(n-k)
LTI Time invariant property
DS
x(k)δ(n-k) x(k)h(n-k) Homogeneity property
LTI
DS
LTI
DS
superposition property
The impulse response of an LTI system is given by h(n). The
mathematical operation in shown above is called a linear convolution
sum and is denoted by
Hence an LTI system is completely characterized in the time domain by
the impulse response h(n) as shown below.
y(n) ={6, 31, 47, 6, -51, -5, 41, 18, -22, -3, 8, 2}
EXAMPLE 2 Determine the Convolution sum the sequences given in
below using manually and using MATLAB
x=[1,-1,2,4,-1,0,0,2]
h=[1,0,-2,-1,2,1]
h=[2,3,0,-5,2,1]
Difference Equation
An LTI discrete system can also be described by a linear constant
coefficient difference equation of the form
MATLAB IMPLEMENTATION
y = filter(b,a,x)
where
are the coefficient arrays from the equation given , and x is the input
sequence array. The output y has the same length as input x. One must
ensure that the coefficient a0 not be zero. We illustrate the use of this
routine in the following example.
EXAMPLE Given the following difference equation
y(n) - y(n - 1) + 0.9y(n - 2) = x(n);
a. Calculate and plot the impulse response h(n) at n = -20,. . . ,100.
b. Calculate and plot the unit step response s(n) at n = -20,. . . ,100.
c. Is the system specified by h(n) stable?
Solution : From the given difference equation the coefficient arrays are
b = [1]; a=[1, -1, 0.9];
a. MATLAB script
Impulse response
b =[1]; 1
n3=[1:120]; 0.2
x1=zeros(1,length(n1));
h(n)
0
x2=ones(1,length(n2));
x3=zeros(1,length(n3)); -0.2
x=[x1,x2,x3]; -0.4
h=filter(b,a,x); -0.6
stem(n,h);
-0.8
title('Impulse response');xlabel('n');
ylabel('h(n)') -1
-20 0 20 40 60 80 100 120
n
b. MATLAB script
step response
2.5
b =[1];
a=[1, -1, 0.9];
n=[-10:200]; 2
n1=[-10:-1];
n2=[0:200]; 1.5
x1=zeros(1,length(n1));
s(n)
x2=ones(1,length(n2));
1
x=[x1,x2];
s=filter(b,a,x);
stem(n,s); 0.5
title('step response');xlabel('n');
ylabel('s(n)') 0
-20 0 20 40 60 80 100 120
n
c. To determine the stability of the system, we have to determine h(n) for
all n. Although we have not described a method to solve the difference
equation, we can use the plot of the impulse response to observe that h(n)
is practically zero for n > 120. Hence the sum ∑lh(n)l can be determined
from MATLAB using
sum(abs(h))
ans= 14.8785
which implies that the system is stable.
b=[1]
a=[1,-1,0.9]
n=[-20:20]
n1=[-20:-1]
n2=[0]
n3=[1:20]
x1=zeros(1,length(n1))
x2=ones(1,length(n2))
x3=zeros(1,length(n3))
x=[x1,x2,x3]
h=filter(b,a,x)
s=sum(abs(h))
Example 1 Consider a DT system given below