Handout - 2 Discrete-Time Systems

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Digital Signal Processing

Using Matlab

Discrete-Time Systems
Overview
• What is a System?
• System Properties
• Convolution
• The Difference Equation

2
What is a System?
A system is any process or device that produces an output
signal in response to an input signal. The notion 𝑇 ∙ is used to
represent a general system (T stands for Transformation).

𝓣∙

𝑥[𝑛] 𝑦[𝑛] = 𝓣 𝑥[𝑛]

3
System Properties
Memoryless System

Definition: A system is said to be memoryless if the output at


any time 𝑛 = 𝑛0 depends only on the input at time 𝑛 = 𝑛0 .

Examples:
• 𝑦[𝑛] = 𝑥 2 [𝑛] is a memoryless system.
• 𝑦[𝑛] = 𝑥[𝑛] + 𝑥[𝑛 − 1] is not a memoryless system.

4
System Properties
Additive System

Definition: A system is said to be additive if


𝓣 𝑥1 [𝑛] + 𝑥2 [𝑛] = 𝓣 𝑥1 [𝑛] + 𝓣 𝑥2 [𝑛] = 𝑦1 [𝑛] + 𝑦2 [𝑛]

Homogeneous System

Definition: A system is said to be homogeneous if


𝓣 𝑐𝑥[𝑛] = 𝑐𝓣 𝑥[𝑛] = 𝑐𝑦[𝑛]
Examples:
𝑥 2 [𝑛]
• The system 𝑦[𝑛] = is not additive but homogeneous.
𝑥[𝑛−1]
• The system 𝑦[𝑛] = 𝑥[𝑛] + 𝑥 ∗ [𝑛 − 1] is additive but not
homogeneous.
5
System Properties
Linear System

Definition: A system that is both additive and homogeneous is said


to be linear. That is
𝓣 𝑎1 𝑥1 [𝑛] + 𝑎2 𝑥2 [𝑛] = 𝑎1 𝓣 𝑥1 [𝑛] + 𝑎2 𝓣 𝑥2 [𝑛]
= 𝑎1 𝑦1 [𝑛] + 𝑎2 𝑦2 [𝑛]

This is called the superposition theorem. Therefore, a system is


said to be linear if it satisfies the principle of superposition.

Examples:
• The system 𝑦[𝑛] = 𝑥 2 [𝑛] is nonlinear.
• The system 𝑦[𝑛] = 𝑥[𝑛] + 𝑥[𝑛 − 1] is linear.

6
System Properties
Shift-Invariant System

Definition: A system is said to be shift-invariant if, for any delay


𝑛0 , the response to 𝑥[𝑛 − 𝑛0 ] is 𝑦[𝑛 − 𝑛0 ]. A system that is not
shift-invariant is said to be shift-varying.
In effect, a system will be shift-invariant if its properties or
characteristics do not change with time. In other words, the system
behaves exactly the same way independently on when it is switched
on, i.e.,
𝓣 𝑥[𝑛 − 𝑛0 ] = 𝑦[𝑛 − 𝑛0 ]
Examples:
• The system 𝑦[𝑛] = 𝑥 2 [𝑛] is shift-invariant.
• The system 𝑦[𝑛] = 𝑛𝑥[𝑛] is shift-varying.
7
System Properties
Linear Shift-Invariant (LSI) System

Definition: A system that is both linear and shift-invariant is


referred to as a linear shift-invariant (LSI) system.
• LSI systems are mathematically easy to analyze and
characterize, and consequently easy to design.
• Many useful signal processing algorithms have been developed
utilizing this class of systems.

8
System Properties
Causal System

Definition: A system is said to be causal if the response of the


system at time 𝑛0 depends only on the input up to time 𝑛 = 𝑛0 .
In other words, the output does not depend on future inputs.
• Causality is a system property that is important for real-time
applications. A causal system is called a realizable system.
• For a causal system, changes in the output cannot precede
changes in the input.
• An LSI system is causal if its unit sample response is causal:
ℎ[𝑛] = 0 for 𝑛 < 0
Examples:
• The system 𝑦[𝑛] = 𝑥[𝑛] + 𝑥[𝑛 − 1] is causal.
• The system 𝑦[𝑛] = 𝑥[𝑛] + 𝑥[𝑛 + 1] is noncausal.
9
System Properties
Stable System

Definition: A system is said to be stable in the Bounded Input-


Bounded Output (BIBO) sense if, for any bounded input,
𝑥[𝑛] ≤ 𝐴 < ∞ ∀𝑛,
the output is also bounded,
𝑦[𝑛] ≤ 𝐵 < ∞ ∀𝑛
where 𝐴 and 𝐵 are positive finite constants.
For an LSI system, stability is guaranteed if and only if the unit
sample response is absolutely summable:

ℎ[𝑛] 1 = ෍ ℎ[𝑛] < ∞


𝑛=−∞
where ℎ[𝑛] is the unit sample response of the LSI system (to be
defined shortly). 10
Convolution
Recall that the input signal 𝑥[𝑛] can be expressed as

𝑥[𝑛] = ෍ 𝑥 𝑘 𝛿[𝑛 − 𝑘]
𝑘=−∞

Therefore, for an LSI system,


∞ ∞

𝑦[𝑛] = 𝓣 𝑥[𝑛] = 𝓣 ෍ 𝑥 𝑘 𝛿[𝑛 − 𝑘] = ෍ 𝑥[𝑘]𝓣 𝛿[𝑛 − 𝑘]


𝑘=−∞ 𝑘=−∞

Let us define ℎ[𝑛] as the response (output) of the LSI system to the
unit sample 𝛿[𝑛], i.e.,

ℎ[𝑛] = 𝓣 𝛿[𝑛]

11
Convolution
In other words, ℎ[𝑛] is the unit sample response of the LSI system.

𝑥[𝑛] = 𝛿[𝑛] ℎ[𝑛] 𝑦[𝑛] = ℎ[𝑛]

where the unit sample response fully characterizes the LSI system.

Then, the response to 𝛿[𝑛 − 𝑘] will be ℎ[𝑛 − 𝑘]. Therefore,


𝑦[𝑛] = ෍ 𝑥 𝑘 ℎ[𝑛 − 𝑘]
𝑘=−∞
This equation is known as the convolution sum and is written as:

𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛] = ෍ 𝑥 𝑘 ℎ[𝑛 − 𝑘]


𝑘=−∞
12
Convolution
Convolution is a very important operation and it says that:
The response (output), 𝒚[𝒏], of a LSI system to any excitation
(input), 𝒙[𝒏], could be found using the convolution sum once
the system’s unit sample response, 𝒉[𝒏], is known.

𝑥[𝑛] ℎ[𝑛] 𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛] = ෍ 𝑥 𝑘 ℎ[𝑛 − 𝑘]


𝑘=−∞

Convolution involves the following four steps:


1. Folding ℎ[𝑘] to obtain ℎ[−𝑘].
2. Shifting ℎ[−𝑘] by 𝑛 samples to get ℎ[𝑛 − 𝑘].
3. Multiplying 𝑥[𝑘] by ℎ[𝑛 − 𝑘].
4. Summing all product values to get 𝑦[𝑛].
13
Convolution
Performing Convolutions

Method 1: Analytical approach


Used when the sequences are described by simple closed-form
expressions
Example:
𝑛 𝑎𝑛 𝑛≥0
Let 𝑥[𝑛] = 𝑎 𝑢[𝑛] = ቊ and ℎ[𝑛] = 𝑢[𝑛]
0 𝑛<0

𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛] = ෍ 𝑥 𝑘 ℎ[𝑛 − 𝑘]


𝑘=−∞
∞ 𝑛 𝑛+1
1 − 𝑎
𝑦[𝑛] = ෍ 𝑎𝑘 𝑢 𝑘 𝑢[𝑛 − 𝑘] = ෍ 𝑎𝑘 = 𝑢[𝑛]
1−𝑎
𝑘=−∞ 𝑘=0 14
Convolution
Performing Convolutions

Method 1: Analytical approach


Closed-form expressions for some common series

15
Convolution
𝑥[𝑘] ℎ[𝑘]

Performing Convolutions

Method 2: Graphical approach ℎ[−𝑘] 𝑥 𝑘 ℎ[−𝑘]


𝑛=0
1. Plot 𝑥[𝑘] and ℎ[𝑘] as a function of 𝑘.
2. Flip ℎ[𝑘] to get ℎ[−𝑘].
3. Shift ℎ[−𝑘] by 𝑛 samples to get ℎ[1 − 𝑘] 𝑥 𝑘 ℎ[1 − 𝑘]
𝑛=1
ℎ[𝑛 − 𝑘]. [Note: If 𝒏 is positive, we
shift to the right. If 𝒏 is negative, we
shift to the left.]
ℎ[2 − 𝑘] 𝑥 𝑘 ℎ[2 − 𝑘]
4. Multiply 𝑥[𝑘] by ℎ[𝑛 − 𝑘]. 𝑛=2

5. Sum the product for all values of 𝑘.


6. Repeat these steps for all possible
y𝑛
values of 𝑛.

Joy of Convolution:
http://www.jhu.edu/~signals/discreteconv2/index.html 𝑛

16
Convolution
Performing Convolutions

Method 3: Simple arithmetic multiplication approach


Example:
𝑥[𝑛] = −1, 2, 3 and ℎ[𝑛] = 1, −1, 3, 2

𝑛 -3 -2 -1 0 1 2

ℎ[𝑛] 1 -1 3 2

𝑥[𝑛] -1 2 3 This is 𝑥[1] × ℎ[1], so


we place it at 𝑛 = 2
3 -3 9 6

2 -2 6 4

-1 1 -3 -2

𝑦[𝑛] -1 3 -2 1 13 6
17
Convolution
Performing Convolutions
1
MATLAB:
N = 15; 0.5

n = [0:N-1];
0
x = (0.7).^n; 0 2 4 6 8 10 12 14
h = ones(1, N); 1
y = conv(x, h);
Subplot(3,1,1); stem(n, x) 0.5

Subplot(3,1,2); stem(n, h);


0
Subplot(3,1,3); stem(0:length(y)-1, y); 0 2 4 6 8 10 12 14
4
• Here we consider all
sequences to start at 𝑛 = 0. 2

• Length of the output


0
sequence is 0 5 10 15 20 25 30
length(x) + length(h) – 1
• y = conv(h, x); gives the same Convolution Demo
result 18
Convolution
Convolution Properties

1. Commutative property:

𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛] = ℎ[𝑛] ∗ 𝑥[𝑛]

2. Associative properties

𝑦[𝑛] = 𝑥 𝑛 ∗ ℎ1 𝑛 ∗ ℎ2 [𝑛]

= 𝑥[𝑛] ∗ {ℎ1 [𝑛] ∗ ℎ2 [𝑛]}

19
Convolution
Convolution Properties

3. Distributive property
𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ1 𝑛 + ℎ2 𝑛 = 𝑥[𝑛] ∗ ℎ1 [𝑛] + 𝑥[𝑛] ∗ ℎ2 [𝑛]

20
The Difference Equation
Linear Constant Coefficient Difference Equation (LCCDE)

• An LSI discrete-time system can also be described by a linear


constant coefficient difference equation (LCCDE) of the form
𝑁 𝑀

෍ 𝑎𝑘 𝑦 𝑛 − 𝑘 = ෍ 𝑏𝑚 𝑥 𝑛 − 𝑚 , ∀𝑛
𝑘=0 𝑚=0

• If 𝑎𝑁 ≠ 0, then the difference equation is of order 𝑁.


• It describes a recursive approach for computing the current
output, given the input values and previously computed
output values.
𝑀 𝑁

𝑦 𝑛 = ෍ 𝑏𝑚 𝑥 𝑛 − 𝑚 − ෍ 𝑎𝑘 𝑦 𝑛 − 𝑘 , ∀𝑛
𝑚=0 𝑘=1
21
The Difference Equation
Solution of the LCCDE

• The solution of the LCCDE has the form


𝑦[𝑛] = 𝑦ℎ [𝑛] + 𝑦𝑝 [𝑛]
where
– 𝑦ℎ [𝑛] is known as the Homogeneous Solution.
– 𝑦𝑝 [𝑛] is known as the Particular Solution.
• Solving the difference equation in the time domain is
sometimes tedious.
• Analytical approach using z-transform will be discussed later.
• Numerical solution with Matlab: y = filter(b,a,x)

22
The Difference Equation
Example

𝑦[𝑛] = 𝑥[𝑛] + 𝑦[𝑛 − 1] − 0.9𝑦[𝑛 − 2]


Find the output if 𝑥[𝑛] = 𝛿[𝑛].

MATLAB:
b = [1];
a = [1, -1, 0.9];
n = -20:120;
x = [n==0];
y = filter(b, a, x);
subplot(2,1,1); stem(n,x)
title(‘Input Signal’); xlabel(‘n’); ylabel(‘x(n)’)
subplot(2,1,2); stem(n,y)
title(‘Impulse Response’); xlabel(‘n’); ylabel(‘y(n) = h(n)’)

23
The Difference Equation
Example Input Signal
1

x(n)
0.5

0
-20 0 20 40 60 80 100 120
n
Impulse Response
1

0.5
y(n) = h(n)

-0.5

-1
-20 0 20 40 60 80 100 120
n
This particular output is the unit sample response of the system, i.e. 𝒉[𝒏].
24
Matlab Commands
conv Convolution and polynomial multiplication
filter 1-D digital filter
subplot Create axes in tiled positions
title Add title to current axes
xlabel Label x-axis
ylabel Label x-axis

25
Useful Links
Discrete Convolution

https://www.youtube.com/watch?v=A6qR7UhLvng

https://www.youtube.com/watch?v=C_kwjJLepLg

26

You might also like