You are on page 1of 30

Discrete-time Systems

Lecture 3
Discrete Systems
Mathematically described as T[.] that take
sequence x(n) and transform to another
sequence y[n]
)] ( [ ) ( n x T n y =
Linear System
A system is linear if and only if
)] ( [ )] ( [ )] ( ) ( [
2 2 1 1 2 2 1 1
n x L a n x L a n x a n x a L + = +
) ( ), ( , ,
2 1 2 1
n x n x a a
Linear System
Output of linear system to an arbitrary input x(n)
L[(n-k)] = h(n,k) is the response of linear system at time nto
a unit sample at time k
Called impulse response
This is a time-varying impulse response h(n,k) which is not
very convenient


=

=
=

= =
n n
k n L k x k n k x L n x L n y )] ( [ ) ( ) ( ) ( )] ( [ ) (

=
=
n
k n h k x n y ) ( ) ( ) (
Linear time-invariant (LTI) System
A linear system in which an input-output pair x(n) and y(n) is
invarient to a shift k in time
The L[.] and shifting operators are reversable
) ( )] ( [ )] ( [ ) ( k n y k n x L n x L n y = =
L[.] Shift by k
Shift by k L[.]
x(n)
y(n)
x(n) y(n-k)
y(n-k)
x(n-k)
Linear time-invariant (LTI) System
Time-invariant function: h(n-k)
Output form:
Impulse response of an LTI system is given by h(n)
the operation is called linear convolution sum *

=
= =
n
k n h k x n x LTI n y ) ( ) ( )] ( [ ) (
h(n) x(n) y(n) = x(n) * h(n)

=
= =
n
k n h k x n h n x n y ) ( ) ( ) ( * ) ( ) (
Stability
Important to consider stability to avoid building harmful
systems or avoid burnout or saturation in system operation
A system is boundary-input boundary-output (BIBO) stable if
every bounded input produces a bounded output
An LTI system is BIBO if and only if its impulse response is
absolutely sumable
y x n y n x , , ) ( ) ( < <
<


) (n h ity BIBOstabil
Causality
Necessary to make sure the system can be built
A system is causal if the output at index n
0
depends only on
the input up to and including index n
0
(output does not depend
on future value)
An LTI system is causal if and only if
0 , 0 ) ( < = n n h
Example of Convolution
let the rectangle pulse x(n)=u(n)-u(n-10) be an input to an LTI system
with impulse response
Determine the output y(n)
Almost geometric series sum except that the term u(n-k) takes different
values depending on n and k
) ( ) 9 . 0 ( ) ( n u n h
n
=

= =

= =
9
0
9
0
) ( ) 9 . 0 ( ) 9 . 0 ( ) ( ) 9 . 0 )( 1 ( ) (
k
k
k
n k n
k n u k n u n y
Example of Convolution
When n<0, u(n-k)=0, 0<=k<=9,
y(n) = 0
When 0<=n<=9, u(n-k)=1, 0<=k<=n
When n <= 9, u(n-k)=1, 0<=k<=9

=

= =
n
k
k n
n
k
k n
n y
0
1
0
] 9 . 0 [ 9 . 0 9 . 0 9 . 0 ) (

=
9
0
) 9 . 0 ( ) 9 . 0 ( ) (
k
k
n n y
] 9 . 0 1 [ 10
9 . 0 1
9 . 0 1
9 . 0
1
1
) 1 (
+

+
=

=
n
n
n
] 9 . 0 1 [ ) 9 . 0 ( 10
9 . 0 1
9 . 0 1
9 . 0
1 9
1
10
+

=
n n n
Example of Convolution
Given the following two sequence
Determine the convolution y(n) = x(n)*h(n)
3 3 ], 2 , 4 , 1 , 0 , 7 , 11 , 3 [ ) ( = n n x
4 1 ], 1 , 2 , 5 , 0 , 3 , 2 [ ) ( = n n h
] 2 , 8 , 3 , 22 , 18 , 41 , 5 , 51 , 6 , 47 , 31 , 6 [ ) ( = n y
0 11 ) 5 ( 3 ) 1 ( ) ( + =

k
k h k x
2 0 3 7 + +
) 1 ( 6 = = y
2 7 1 11 ) 2 ( ) ( + =

k
k h k x
0 ) 1 ( ) 5 ( 0 + +
2 2 3 4 + +
) 2 ( 41 y = =
MATLAB Implementation
>> x=[ 3, 11, 7, 0, - 1, 4, 2] ;
>> h=[ 2, 3, 0, - 5, 2, 1] ;
>> y = conv( x, h)
y =
6 31 47 6 - 51 - 5 41 18 - 22 - 3 8 2
>>
conv function computes convolution between two finite
duration sequences, assuming the two sequences begin at
n=0
MATLAB Implementation
f unct i on [ y, ny] = conv_m( x, nx, h, nh)
nyb = nx( 1) +nh( 1) ;
nye = nx( l engt h( nx) ) + nh( l engt h( nh) ) ;
ny = [ nyb: nye] ;
y = conv( x, h) ;
Given a finite duration x(n) and h(n),
The beginning and ending points of y(n) are
>> [ y, ny] =conv_m( x, nx, h, nh)
y =
6 31 47 6 - 51 - 5 41 18 - 22 - 3 8 2
ny =
- 4 - 3 - 2 - 1 0 1 2 3 4 5 6 7
} ); ( {
xe xb
n n n n x } ); ( {
he hb
n n n n h and
hb xb yb
n n n + =
he xe ye
n n n + =
and
Sequence Correlation Revisited
The cross correlation can be put in the form
With autocorrelation in the form
) ( * ) ( ) ( l x l y l r
yx
=
) ( * ) ( ) ( l x l x l r
xx
=
example of the crosscorrelation sequence
Let this be a prototype sequence
Let y be its noise-corrupted-and-shifted version
Where w(n) is a Gaussian sequence with mean 0 and variance 1
Compute crosscorrelation between y(n) and x(n)
] 2 , 4 , 1 , 0 , 7 , 11 , 3 [ ) ( =

n x
) ( ) 2 ( ) ( n w n x n y + =
Example of the crosscorrelation sequence
>> x = [ 3 11 7 0 - 1 4 2] ;
>> nx = [ - 3: 3] ;
>> [ y, ny] = si gshi f t ( x, nx, 2) ;
>> w=r and( 1, l engt h( y) ) ; nw=ny;
>> [ y, ny] =si gadd( y, ny, w, nw) ;
>> [ x, nx] =si gf ol d( x, nx) ;
>> [ r xy, nr xy] =conv_m( y, ny, x, nx) ;
>> subpl ot ( 1, 1, 1) , subpl ot ( 2, 1, 1) ; st em( nr xy, r xy) ;
>> axi s( [ - 5, 10, - 50, 250] ) ; xl abel ( ' l ag var i abl e l ' ) ;
>> yl abel ( ' r xy' ) ;
Example of the crosscorrelation sequence
>> x = [ 3 11 7 0 - 1 4 2] ;
>> nx = [ - 3: 3] ;
>> [ y, ny] = si gshi f t ( x, nx, 2) ;
>> [ r xy, nr xy] =xcor r ( x, y) ;
>> subpl ot ( 1, 1, 1) , subpl ot ( 2, 1, 1) ; st em( nr xy, r xy) ;
>> axi s( [ - 5, 10, - 50, 250] ) ; xl abel ( ' l ag var i abl e l ' ) ;
>> yl abel ( ' r xy' ) ;
crosscorrelation and autocorrelation
>> x = [ 3 11 7 0 - 1 4 2] ;
>> nx = [ - 3: 3] ;
>> [ y, ny] = si gshi f t ( x, nx, 2) ;
>> [ r xy, nr xy] =xcor r ( x, y) ;
>> st em( nr xy, r xy) ; axi s( [ - 5, 10, - 50, 250] ) ; xl abel ( ' l ag var i abl e l ' ) ; yl abel ( ' r xy' ) ;
>> [ r xx, nr xx] =xcor r ( x) ;
>> st em( nr xx, r xx) ; axi s( [ - 5, 10, - 50, 250] ) ; xl abel ( ' l ag var i abl e l ' ) ; yl abel ( ' r xx' ) ;
Different Equations
An LTI discrete system can also be described by a linear
constant coefficient different equation of the form
If a
N
0, then the equation is of order N
Another form is
n m n x b k n y a
N
k
M
m
m k
= =
=
0 0
), ( ) (

= =
=
N
k
k
M
m
m
k n y a m n x b n y
0 0
) ( ) ( ) (
Different Equations
The solution of this equation can be obtained in the form
The homogenous part of the solution, y
H
(n) is given by
Where zk, k=1..N are N roots (called natural frequencies) of
the characteristic equation
) ( ) ( ) ( n y n y n y
P H
+ =

=
=
N
k
n
k k H
z c n y
0
) (

=
=
N
k
k
k
z a
0
0
Different Equations
The system is stable if the roots z
k
satisfy the condition
Then the causal system is stable
Where zk, k=1..N are N roots (called natural frequencies) of
the particular part y
P
(n) is determined from
N k z
k
,..., 1 , 1 = <

=
=
N
k
k
k
z a
0
0

=

M
m
m
m n x b
0
) (
MATLAB Implementation
filter function to solve different equation
Its simplest form:
Where
impz function is used to compute and plot impulse
response
y = f i l t er ( b, a, x)
b = [ b0, b1, , bM] ;
a = [ a0, a1, , aN] ;
h = i mpz( b, a, n) ;
Example
Given a difference equation
Calculate and plot the unit step response h(n) at n = -20,,120
n n x n y n y n y = + ); ( ) 2 ( 9 . 0 ) 1 ( ) (
>> b=[ 1] ; a=[ 1, - 1, 0. 9] ; n=[ - 20: 120] ;
>> h=i mpz( b, a, n) ;
>> xl abel ( ' n' ) ; yl abel ( ' h( n) ' ) ;
Example
Given a difference equation
Calculate and plot the unit step response s(n) at n = -20,,120
n n x n y n y n y = + ); ( ) 2 ( 9 . 0 ) 1 ( ) (
>> b=[ 1] ; a=[ 1, - 1, 0. 9] ; n=[ - 20: 120] ;
>> x=st epseq( 0, - 20, 120) ; s= f i l t er ( b, a, x) ;
>> st em( n, s) ;
>> xl abel ( ' n' ) ; yl abel ( ' s( n) ' ) ;
Example
Given a difference equation
Is the system specified by h(n) stable?
We can use the plot of the impulse response to observe that h(n) is
practically zero for n > 120. We can check if
Therefore, the system is stable
n n x n y n y n y = + ); ( ) 2 ( 9 . 0 ) 1 ( ) (
>> sum( abs( h) )
ans =
14. 8785
>> z = r oot s( a) ; magz = abs( z)
magz =
0. 9487
0. 9487
The sum is less than infinity
The roots are less than one
<


) (n h
N k z
k
,..., 1 , 1 = < or
Example (cont.)
By definition h(n) is the output of an LTI system when the
input is (n)
Substituting x(n) for (n) and y(n) for h(n), the difference eq. is
) ( ) 1 ( 9 . 0 ) ( n x n y n y =
>> a=[ 1, - 1, 0. 9] ; b=1;
>> x=i mpseq( 0, - 20, 120) ; n=[ - 20: 120] ;
>> h=f i l t er ( b, a, x) ;
>> st em( n, h) ;
>> axi s( [ - 20, 120, - 1. 1, 1. 1] )
>> t i t l e( ' I mpul se Response' ) ;
>>xl abel ( ' n' ) ; yl abel ( ' h( n) ' ) ;
Zero-Input and Zero State Response
Difference eq. is solved forward in time from n=0
Initial condition on x(n) and y(n) are necessary to determine the output for
n >=0. The initial condition is given by
Subject to the initial conditions:
A solution can be obtained in the form
yZI(n) is called zero-input solution: due to the initial conditions alone
(assuming they exist)
yZS(n) is called zero state solution: due to input x(n) alone
(assuming the initial conditions are zero)
0 ; ) ( ) ( ) (
0 0
=

= =
n k n y a m n x b n y
N
k
k
M
m
m
} 1 ); ( { n N n y } 1 ); ( { n M n x
) ( ) ( ) ( n y n y n y
ZS ZI
+ =
Digital Filters
Filter means LTI system designed for a
specific job of frequency selection or
discrimination
FIR (Finite-duration Impulse Response) Filters
the unit impulse response of the LTI system is of finite duration
h(n) = 0 for n < n1 and n > n2
Causal FIR filter:
h(0) = b
0
, h(1) = b
1
, h(2) = b
2
h(M) = b
M
. Other h(n) are 0
Also called nonrecursive or moving average (MA) filter.
Represented as impulse response {h(n)}or as difference eq. coefficient
{b
m
}and {a
0
= 1}
We can use either conv(x,h) or filter(b,1,x)
Output of conv(x,h) has longer length than both x(n) and h(n)
Output of filter(b,1,x) has same length as x(n)

=
=
M
m
m
m n x b n y
0
) ( ) (
IIR (Infinite-duration Impulse Response) Filters
the impulse response of the LTI system is of infinite duration
The part of difference eq:
output y(n) is recursively computed from previously computed values
Also called autoregressive (AR) filter.
This is also decribes IIR filter
called autoregressive moving average (ARMA) filter
Described by difference eq. coefficients {bm}and {ak}, implemented by
filter(b,a,x)
) ( ) (
0
n x k n y a
N
k
k
=

=
n m n x b k n y a
N
k
M
m
m k
= =
=
0 0
), ( ) (

You might also like