Professional Documents
Culture Documents
Pengolahan Sinyal Digital: Adhi Harmoko Saputro
Pengolahan Sinyal Digital: Adhi Harmoko Saputro
DSP - Fisika UI
2
Differential Equations
Adhi Harmoko Saputro
DSP - Fisika UI
3
LTI System
Convolution y [ n] x [ n] ∗ h [ n]
Signal
LTI System
N M
Differential ∑ ak y [ n=
− k ] ∑ bk x [ n − k ]
Equations
= k 0= k 0
DSP - Fisika UI
4
=
k
k 0= k 0
∑ a y [ n=
− k ] ∑ b x [n − k ]k
DSP - Fisika UI
5
=
k
k 0= k 0
∑ a y [n − k ] = ∑ b x [n − k ]
k where ak = bk = 1
DSP - Fisika UI
6
Recursive Solution
• In the discrete-time case, there are an alternative to find the Differential Equations
1M N
y [ n]
= ∑ bx x [ n − k ] − ∑ ak y [ n − k ]
= ao k 0=k 1
• This is often how digital filters are implemented on a computer or a digital signal
processor board
• The response of a differential equation
• The differential equation is discretized at a given sampling rate to obtain a
difference equation
• The response of the difference equation is computed recursively
DSP - Fisika UI
7
General Solution
• A general solution can be expressed as the sum of a homogeneous response
(natural response), and a particular solution (forced response) of the system:
y [ n ] yh [ n ] + y p [ n ]
=
• The concept of initial rest of the LTI causal system described by the difference
equation here means that x[n] = 0 implies y[n] = 0
DSP - Fisika UI
8
General Solution
• The homogeneous part of the solution
N
yh [ n ] = ∑ ck zkn
k =1
∑ k =0
a z
k =1
k
DSP - Fisika UI
9
General Solution
• The particular part of the solution is determined from the right-hand side
x[n] yp[n]
A K
A.Mn K.Mn
A.nM K0nM + K1nM-1 + K2nM-2 + … + KM
An.nM An ( K0nM + K1nM-1 + K2nM-2 + … + KM )
DSP - Fisika UI
10
Example
• Consider the difference equation
DSP - Fisika UI
11
Example
• Solution: Assumption homogen solution
yh[n] = zn
DSP - Fisika UI
12
Example
• Solution
y [ n ] yh [ n ] + y p [ n ]
=
y [ n ] = a1 (−1) n + a2 (4) n
DSP - Fisika UI
13
Example
• Finding a1 and a2 to fulfil the solution
DSP - Fisika UI
14
Example
• Input the initial value
y[0] = 15
y[1] = 65
15= a1 + a2 a1 = −1
65 =−a1 + 4a2 a2 = 16
• Solution
y[n] =−1( −1) + 16 ( 4 )
n n
n≥0
DSP - Fisika UI
15
Example
• Consider the difference equation
5 1
y [ n ] − y [ n − 1] + y [ n − =
2] 3 x [ n ] − 2 x [ n − 1]
6 6
• Find the recursive form of the difference equation
• Assuming initial rest and that the input is an impulse,
• y[−2] = y[−1] = 0
DSP - Fisika UI
16
Example
5 1
y [=
n] y [ n − 1] − y [ n − 2] + 3 x [ n ] − 2 x [ n − 1]
6 6
• the recursion can be started
5 1
y [ 0=
] y [ −1] − y [ −2] + 3x [0] − 2 x [ −1]
6 6
5 1
= ( 0 ) − ( 0 ) + 3 (1) − 2 ( 0 ) = 3
6 6
5 1
[1] y [0] − y [ −1] + 3x [1] − 2 x [0]
y=
6 6
5 1 1
= ( 3) − ( 0 ) + 3 ( 0 ) − 2 (1) =
6 6 2
DSP - Fisika UI
17
Example
5 1
y [ 2] = y [1] − y [ 0] + 3 x [ 2] − 2 x [1]
6 6
51 1 1
= − ( ) ( ) ( )
3 + 3 0 − 2 0 = −
62 6 12
DSP - Fisika UI
18
Matlab Implemantation
• A function called filter is available to solve difference equations numerically, given
the input and the difference equation coefficients.
• In its simplest form this function is invoked by
y = filter(b,a,x)
• where
• b = [b0, b1, ..., bM]; a = [a0, a1, ..., aN] are the coefficient arrays
N M
=
k
k 0= k 0
∑ a y [ n=
− k ] ∑ b x [n − k ]k
DSP - Fisika UI
19
Matlab Implemantation
• To compute and plot impulse response, MATLAB provides the function impz.
• When invoked by
h = impz(b,a,n)
• Computes samples of the impulse response of the filter at the sample indices
given in n with numerator coefficients in b and denominator coefficients in a.
DSP - Fisika UI
20
Matlab Example
• Given the following difference equation
DSP - Fisika UI
21
Matlab Example
• From the given difference equation the coefficient arrays are
• b = [1]; a=[1, -1, 0.9];
DSP - Fisika UI
22
Matlab Example
>> n=-20:100;
>> x = (n-0) >= 0; % x = stepseq(0,-20,100);
>> s = filter(b,a,x);
>> subplot(2,1,2); stem(n,s)
>> title(’Step Response’);
>> xlabel(’n’); ylabel(’s(n)’)
DSP - Fisika UI
23
Matlab Example
Impulse Response Step Response
1 2.5
0.8
0.6 2
0.4
0.2 1.5
s(n)
h(n)
-0.2 1
-0.4
-0.6 0.5
-0.8
-1 0
-20 0 20 40 60 80 100 120 -20 0 20 40 60 80 100
n n
DSP - Fisika UI
24
Matlab Example
• 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
∑ h [ n]
>> sum(abs(h))
ans = 14.8785
which implies that the system is stable.
DSP - Fisika UI
25
Example
• Let us consider the convolution given in previous example. The input sequence is
of finite duration x(n) = u(n) − u(n − 10)
• while the impulse response is of infinite duration
h ( n ) = ( 0.9 ) u ( n )
n
DSP - Fisika UI
26
Example
• If the LTI system, given by the impulse response h(n), can be described by a
difference equation, then y(n) can be obtained from the filter function.
• From the h(n) expression
[ n − 1] ( 0.9 )( 0.9 )
( 0.9 ) h= [ n − 1] ( 0.9 ) u [ n − 1]
n −1 n
u=
h [ n ] − ( 0.9 ) h=
[ n − 1]
( 0.9 ) u [ n] − ( 0.9 ) u [ n − 1]
n n
= ( 0.9 ) ( u [ n ] − u=
[ n − 1]) ( 0.9 ) δ [ n]
n n
= δ [ n]
DSP - Fisika UI
27
Example
• The last step follows from the fact that δ(n) is nonzero only at n = 0.
• By definition h(n) is the output of an LTI system when the input is δ(n).
• Hence substituting x(n) for δ(n) and y(n) for h(n), the difference equation is
y [ n ] − ( 0.9 ) y [ n − 1] =x [ n]
DSP - Fisika UI
28
Example
• MATLAB’s filter function can be used to compute the convolution indirectly.
DSP - Fisika UI
29
Example
Convolotion
8
y(n)
2
0
0 5 10 15 20 25 30 35 40
Differential Equation
8
4
y(n)
-5 0 5 10 15 20 25 30 35 40 45 50
DSP - Fisika UI
30
Example
DSP - Fisika UI
32
DIGITAL FILTERS
Adhi Harmoko Saputro
DSP - Fisika UI
33
DIGITAL FILTERS
• Two types of digital filters
• FIR filter If the unit impulse response of an LTI system is of finite duration, then
the system is called a finite-duration impulse response (or FIR) filter.
M
y [ n]
= ∑ b x [ n − m]
m
m=0
• IIR filter If the impulse response of an LTI system is of infinite duration, then the
system is called an infinite-duration impulse response (or IIR) filter.
N
∑ a y [n − k ] =
k =0
k x [ n]
DSP - Fisika UI
34
Matlab Implementation
• FIR filters are represented either as impulse response values {h(n)} or as difference
equation coefficients {bm} and {a0 = 1}.
• conv(x,h)
• filter(b,1,x)
• IIR filters are described by thedifference equation coefficients {bm} and {ak}
• filter(b,a,x)
DSP - Fisika UI
35
Terima Kasih
Adhi Harmoko Saputro
DSP - Fisika UI