Chapter 2 Systems
Chapter 2 Systems
(Chapter 2)
1
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Systems
2
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
System Examples
◼ Delay
y[n] = x[n − n0 ]
◼ Moving Average
M −1
x[n − k ]
1
y[n] =
M k =0
3
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Moving Average Filter
Moving window (sliding window) filter operator
M=5
x[3]
M −1
x[n − k ]
1
y[n] =
M k =0
y[2]
4
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Moving Average Filter
Moving window (sliding window) filter operator
M=5
x[3]
M −1
x[n − k ]
1
y[n] =
M k =0
y[3]
5
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
System Types
◼ Linear y[n] = T {ax1[n] + bx2 [n]} = aT {x1[n]} + bT {x2 [n]}
Sum of inputs produces a sum of outputs (i.e., superposition applies).
Scaled input produces a scaled output.
A weighted sum of inputs produces is a weighted sum of outputs.
xk [n] → yk [n]
7
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Linear Time Invariant (LTI)
◼ For an LTI system, we can completely specify
it by its impulse response
[n] → h[n]
[n] 1 h[n]
0 n 0 n
8
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Linear Time Invariant (LTI)
◼ For an LTI system, we can completely specify
it by its impulse response and can compute
the output for any input using convolution
[n] → h[n]
[n − k ] → h[n − k ] (TI)
a [n − k ] → a h[n − k ]
k
k
k
k (LTI)
x[n] = x[k ] [n − k ] → y[n] = x[k ]h[n − k ]
k =− k =−
(LTI)
Convolution
9
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Discrete Convolution
◼ Convolution operator
y[n] = x[n]* h[n] = x[k ]h[n − k ]
k =−
◼ Note when you do discrete convolution, you are
implementing the system!
◼ Approaches to computing y[n]
◼ I Sum of impulse responses
◼ For short finite x[n] and h[n] only
◼ II Analytic sum
◼ Use pictures and equations to get a closed form solution for any
convolution
◼ III Numerically (MATLAB)
◼ For more: see the joy of convolution
◼ http://www.jhu.edu/signals/discreteconv2/index.html
10
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
1.5
1
-1
Sum of 1 1
Impulse 1.5
Responses
1.5
Approach
-1 -1
Given x[n] and h[n], find expression for y[n] valid for all n
12
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Summation Formulae
◼ Divergent series sum
N
N ( N + 1)
k =1
k=
2
Gauss Legend
1
◼ Infinite exponential sum a =
k
, |a | 1
k =0 1− a
n2 +1
−
n2 n1
a a
◼ Finite exponential sum ak = , a 1
k = n1 1− a
13
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 1
x[n] = n u (n)
y[n] = x[k ]h[n − k ]
k =− h[n] = n u (n)
x[n] n
…
0 n
h[n] n
…
0 n
14
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 1
x[n] = n u (n)
y[n] = x[k ]h[n − k ]
k =− h[n] = n u (n)
x[k ] k
…
0 k
h[k ] k
…
0 k
15
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 1
x[n] = n u (n)
y[n] = x[k ]h[n − k ]
k =− h[n] = n u (n)
x[k ] k
…
0 k
h[n − k ]
n−k
…
0 k
n
16
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 1
x[n] = n u (n)
y[n] = x[k ]h[n − k ]
k =− h[n] = n u (n)
x[k ] k
…
0 k
h[nh[−nhk[−n]hk[−n]hk[−]nk−] k ]
n− kn− kn− kn− kn − k
… … … … …
0 k
n =n−=2n−=
1 n0=n1= 2
17
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 1
x[n] = n u (n)
y[n] = x[k ]h[n − k ]
k =− h[n] = n u (n)
Region I
n<0 x[k ]
y[n]=0 k
…
0 k
h[n − k ]
n−k
…
n 0 k
18
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 1
For Region II only we can write
Region II n0 n
y[n] =
k n−k
k =0
x[k ] k
( )
n
−1
k y[n] = n
… k =0
0 k
a n1 − a n2 +1
n2
h[n − k ] k
a =
1− a
, a 1
n−k k = n1
0
n k
y[n] = n (
1 − )
−1 n +1
(
1 − −1 )
19
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 1
0 n0
Full Solution
as a piecewise function y[n] = n 1 − (
−1 n +1
)
n0
( )
(don’t forget ALL the pieces!) −1
1 −
20
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution Example 2
x[n] = n u (n)
y[n] = x[k ]h[n − k ]
k =− h[n] = u (n) − u (n − N )
21
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Figure 2.10 Sequence involved
in computing a discrete
convolution. (a)–(c) The
sequences x[k] and h[n− k] as a
function of k for different values
of n. (Only nonzero samples are
shown.) (d) Corresponding
output sequence as a function
of n.
22
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution in MATLAB
◼ conv( )
conv Convolution and polynomial multiplication.
C = conv(A, B) convolves vectors A and B. The resulting vector is
length MAX([LENGTH(A)+LENGTH(B)-1,LENGTH(A),LENGTH(B)]). If A and B are
vectors of polynomial coefficients, convolving them is equivalent to
multiplying the two polynomials.
figure(1)
Without an n array,
stem(x)
MATLAB plots vs.
title('x[n]')
element number
starting with 1 (not
figure(2)
necessarily the
stem(h)
desired n)
title('h[n]')
figure(3)
stem(y)
title('y[n]')
24
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution in MATLAB
◼ Full convolution output length is:
length(x) + length(h) – 1
◼ conv( ) command does not track where on the n
axis any of the signals lie (amplitudes only)
◼ You need to keep track of the independent variable, n,
for your x, h, and y arrays
◼ The first n value of the y array is the sum of the first n
25
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Convolution in MATLAB
Example 2: h=ones(1,3);
nh = [-1:1];
In general, the first n
value of the y array is the
x = ones(1,5); sum of the first n value of
nx = [4:8]; the x array and the first n
y = conv(x,h); value of the h array
ny1 = nx(1) + nh(1)
ny = [ ny1 : ny1 + length(y)-1 ];
figure(1)
stem(nx,x)
xlabel('n')
ylabel('x[n]')
title('Signal')
figure(2)
stem(nh,h)
xlabel('n')
ylabel('h[n]')
title('Impulse Response')
figure(3)
stem(ny,y)
xlabel('n')
ylabel('y[n]')
title('Output')
Chapter 2/run_conv_examples.m 26
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Anything convolved with a delta…
◼ Convolution y[n] = x[n]* h[n] = x[k ]h[n − k ]
k =−
◼ Anything convolved with a delta is itself
y[n] = x[n]* [n] = x[k ] [n − k ] = x[n]
k =−
◼ Anything convolved with a delta shifted it itself shifted
y[n] = x[n]* [n − n0 ] = x[k ] [n − k − n ] = x[n − n ]
k =−
0 0
h[n] y[n]
x[n]
y[n] = h[n]* x[n] = h[k ]x[n − k ]
k =−
28
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Properties of LTI Systems
x[n]* h1[n]
◼ Associative
Associative Property
29
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Properties of LTI Systems
◼ Distributive x[n]* h1[n]
x[n]* h2 [n]
y[n] = ( x[n]* h1[n]) + ( x[n]* h2 [n])
= x[n]* ( h1[n] + h2 [n])
Distributive Property
30
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Inverse System
x[n] y[n]
h1[n] h2[n]
31
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
BIBO Stable
◼ LTI is BIBO stable if impulse
response is absolutely summable
y[n] = x[n]* h[n] = x[k ]h[n − k ]
k =− BIBO Stable?
| y[n] |=| x[n]* h[n] | | x[k ] || h[n − k ] |
k =−
h[n] = .5n u ( n)
h[n] = .5n u ( −n)
| y[n] | B x | h[n − k ] |
k =− h[n] = 2n u (n)
BIBO Stable if
h[n] = u (n)
| h[n − k ] | , | h[k ] |
k =− k =−
h[n] = cos( n)
32
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
Causality This one responds at the impulse
(NOT before) - Causal
[n] h[n]
0 n 0 n
h[n]
[n]
0 n 0 n
34
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
LTI System Example 2
1 4
y[n] =
5 k =0
x[n − k ] •BIBO Stable because h[n] is absolutely
summable
•Causal because h[n] does NOT start
before n=0
•Inverse ?
1 4
h[n] =
5 k =0
[n − k ]
h[n]* hI [n] = [n]
hI [n] = ????
h[n]
1/5 …
…
35
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
LTI System Example 3
•BIBO Stable because h[n] is absolutely
summable
h[n] = .5n u[n]
| h[n] |
1
ak = , |a | 1
n =− k =0 1− a
1
| .5 |=
n
=2
n =0 1 − .5
1
h[n] 1/2 •Causal because h[n] does NOT start
1/4 before n=0
1/8 •Inverse ?
1/16 …
39
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
LCCDE
N M
a y[n − k ] = b
k =0
k
m =0
m x[ n − m]
42
COPYRIGHT © R. C. HARDIE. ALL RIGHTS RESERVED.
FIR or IIR?
◼ How to know if an LCCDE corresponds
to an FIR or IIR?
◼ Easy, look for recursion. Any recursive
LCCDE corresponds to an IIR.
◼ Recursion means the output now depends
on the output at some other time and
possibly the input as well.