Pengolahan Sinyal Digital: Adhi Harmoko Saputro
Pengolahan Sinyal Digital: Adhi Harmoko Saputro
DSP - Fisika UI
2
DSP - Fisika UI
3
Signal Types
• Analog signals: continuous in time and amplitude
• Example: voltage, current, temperature,…
• Digital signals: discrete both in time and amplitude
• Example: attendance of this class, digitizes analog signals,…
• Discrete-time signal: discrete in time, continuous in amplitude
• Example: hourly change of temperature in Jakarta
DSP - Fisika UI
4
Signal Types
• Theory for digital signals would be too complicated
• Requires inclusion of nonlinearities into theory
• Theory is based on discrete-time continuous-amplitude signals
• Most convenient to develop theory
• Good enough approximation to practice with some care
• In practice we mostly process digital signals on processors
• Need to take into account finite precision effects
• Our text book is about the theory hence its title
• Discrete-Time Signal Processing
DSP - Fisika UI
5
-3 -2 -1 0 1 2 3 4
x [ n ] xc ( nT ) −∞ < n < ∞
=
DSP - Fisika UI
6
DSP - Fisika UI
7
Periodic Sampling
• Sampling is, in general, not reversible
• Given a sampled signal one could fit infinite continuous signals through the
samples
0.5
-0.5
-1
0 20 40 60 80 100
DSP - Fisika UI
8
Periodic Sampling
• Fundamental issue in digital signal processing
• If we loose information during sampling we cannot recover it
• Under certain conditions an analog signal can be sampled without loss so that it
can be reconstructed perfectly
0.5
-0.5
-1
0 20 40 60 80 100
DSP - Fisika UI
9
Representation of Sampling
• Mathematically convenient to represent in two stages
• Impulse train modulator
• Conversion of impulse train to a sequence
s(t)
Convert impulse
train to
xc(t) x discrete-time x[n]=xc(nT)
sequence
xc(t)
s(t) x[n]
t n
-3T-2T -T 0 T 2T 3T 4T -3 -2 -1 0 1 2 3 4
DSP - Fisika UI
10
DSP - Fisika UI
11
x[n]
= x[n]} { , x [ −1] , x [ 0] , x [1] ,}
{=
• Often times sequences are obtained by sampling of continuous-time signals
• In this case x[n] is value of the analog signal at xc(nT)
• Where T is the sampling period
DSP - Fisika UI
12
-10
0 20 40 60 80 100 t (ms)
10
-10
0 10 20 30 40 50 n (samples)
DSP - Fisika UI
13
[ n]
x= {2,1, −1,0,1, 4,3,7}
↑
• represented in MATLAB
DSP - Fisika UI
14
y[=
n] x[n − no ] 1
0.5
• Unit sample (impulse) sequence
0
-10 -5 0 5 10
0 n ≠ 0 1.5
δ [ n] =
1 n = 0 1
0
0 n < 0 -10 -5 0 5 10
u[n] = 1
1 n ≥ 0
• Exponential sequences 0.5
0
x[n] = Aα n -10 -5 0 5 10
DSP - Fisika UI
15
Sinusoidal Sequences
• Important class of sequences
= x [ n ] cos (ωo n + ϕ )
• An exponential sequence with complex
= e jωo and A
α α= A e jϕ
[ n] A= α e= A α e j (ω n +ϕ )
jϕ n jωo n n
x= α n
Ae o
DSP - Fisika UI
16
Sinusoidal Sequences
• Different from continuous-time, discrete-time sinusoids
• Have ambiguity of 2πk in frequency
cos ( (ωo + 2π k ) n +=
ϕ ) cos (ωo n + ϕ )
• Are not necessary periodic with 2π/ωo
2π k
cos (ωo n +=
ϕ ) cos (ωo n + ωo N + ϕ ) only if
= N is an integer
ωo
DSP - Fisika UI
17
MATLAB Example 1
• Create sequence
0 n ≠ 0
δ [n − no ] =
1 n = 0
• over the 0 ≤ n ≤ 10 interval, with no = 5
n0 = 5;
n1 = 0;
n2 = 10;
n = n1:n2;
x = (n-n0) == 0; stem(n, x);
DSP - Fisika UI
18
n0 = 5;
n1 = 0;
n2 = 10;
[x,n] = impseq(n0,n1,n2); stem(n, x);
DSP - Fisika UI
19
MATLAB Example 2
• Create sequence
0 n < 0
u[n − no ] =
1 n ≥ 0
• over the 0 ≤ n ≤ 10 interval, with no = 5
n0 = 5;
n1 = 0;
n2 = 10;
DSP - Fisika UI
20
n0 = 5;
n1 = 0;
n2 = 10;
[x,n] = stepseq(n0,n1,n2); stem(n, x);
DSP - Fisika UI
21
MATLAB Example 3
• Create sequence
x [ n ] = ( 0.9 )
n
n = 0:10;
x = (0.9).^n;
stem(n,x);
DSP - Fisika UI
22
MATLAB Example 4
• Create sequence
x [ n ] = exp ( 2 + j 3) n
n = 0:10;
x = exp((2+3j)*n);
subplot(211); stem(n,imag(x));
subplot(212); stem(n,real(x));
DSP - Fisika UI
23
MATLAB Example 5
• Create sequence
n = 0:10;
x = 3*cos(0.1*pi*n+pi/3)+2*sin(0.5*pi*n);
stem(n,x);
DSP - Fisika UI
24
Operations on Sequences
• Signal addition: { x [ n]} + { x [ n]} ={ x [ n] + x [ n]}
1 2 1 2
Operations on Sequences
• Signal multiplication: { x [ n]}.{ x [ n]} = { x [ n] x [ n]}
1 2 1 2
DSP - Fisika UI
26
Operations on Sequences
• Scaling:
α { x [ n ]} = {α x [ n ]}
DSP - Fisika UI
27
Operations on Sequences
• Shifting: each sample of x[n] is shifted by an amount k to obtain a shifted
sequence y[n].
[ n]
y= { x [ n − k ]}
• If m = n−k, then n = m+k and the above operation is given by
{ x [ m]}
y [m + k ] =
DSP - Fisika UI
28
Operations on Sequences
• 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]}
function [y,n] = sigfold(x,n)
% implements y(n) = x(-n)
% -----------------------
% [y,n] = sigfold(x,n)
%
y = fliplr(x); n = -fliplr(n);
• Sample summation: This operation differs from signal addition operation. It adds
all sample values of x(n) between n1 and n2.
n2
∑ x [ n=] x [ n ] + + x [ n ]
n = n1
1 2
DSP - Fisika UI
29
Operations on Sequences
• Sample products: This operation also differs from signal multiplication operation.
• It multiplies all sample values of x(n) between n1 and n2.
n2
∏ x [ n=] x [ n ] × × x [ n ]
n1
1 2
∞ ∞
2
=εx x [ n] x * [ n] ∑ x [ n]
∑=
−∞ −∞
DSP - Fisika UI
30
Operations on Sequences
• Signal power: The average power of a periodic sequence x[n] with fundamental
period N is given by
1 N −1 2
Px = ∑ x [ n ]
N 0
DSP - Fisika UI
31
MATLAB Example 6
• Generate and plot each of the following sequences over the indicated interval
n = -5:5;
x = 2*impseq(-2,-5,5) - impseq(4,-5,5);
stem(n,x); title(’Sequence in MATLAB Example 6’)
xlabel(’n’); ylabel(’x(n)’);
DSP - Fisika UI
32
MATLAB Example 6
• Generate and plot each of the following sequences over the indicated interval
1.5
0.5
x(n)
-0.5
-1
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
DSP - Fisika UI
33
MATLAB Example 7
• Generate and plot each of the following sequences over the indicated interval
n = [0:20];
x1 = n.*(stepseq(0,0,20)-stepseq(10,0,20));
x2 = 10*exp(-0.3*(n-10)).*(stepseq(10,0,20)- ...
stepseq(20,0,20));
x = x1+x2;
stem(n,x);
title(’Sequence in MATLAB Example 7’)
xlabel(’n’); ylabel(’x(n)’);
DSP - Fisika UI
34
MATLAB Example 7
• Generate and plot each of the following sequences over the indicated interval
x(n) = n[u(n)−u(n−10)]+10e −0.3(n−10)[u(n−10)−u(n−20)],
0 ≤ n ≤ 20
Sequence in MATLAB Example 7
10
5
x(n)
0
0 2 4 6 8 10 12 14 16 18 20
n
DSP - Fisika UI
35
MATLAB Example 8
• Generate and plot each of the following sequences over the indicated interval
x(n) = cos(0.04πn) + 0.2w(n), 0 ≤ n ≤ 50
w(n) is a Gaussian random sequence with zero mean and unit variance
n = 0:50;
x = cos(0.04*pi*n)+0.2*randn(size(n));
stem(n,x);
title('Sequence in MATLAB Example 8')
xlabel('n'); ylabel('x(n)');
DSP - Fisika UI
36
MATLAB Example 8
• Generate and plot each of the following sequences over the indicated interval
x(n) = cos(0.04πn) + 0.2w(n), 0 ≤ n ≤ 50
w(n) is a Gaussian random sequence with zero mean and unit variance
Sequence in MATLAB Example 8
1.5
0.5
0
x(n)
-0.5
-1
-1.5
0 5 10 15 20 25 30 35 40 45 50
n
DSP - Fisika UI
37
MATLAB Example 9
• Generate and plot each of the following sequences over the indicated interval
• Note that over the given interval, the sequence ˜x (n) has four periods
DSP - Fisika UI
38
MATLAB Example 10
• Let
{ }
x [ n ] = 1, 2,3, 4,5,6,7,6,5, 4,3, 2,1
↑
DSP - Fisika UI
39
MATLAB Example 10
{ }
x [ n ] = 1, 2,3, 4,5,6,7,6,5, 4,3, 2,1
↑
DSP - Fisika UI
40
DSP - Fisika UI
41
DSP - Fisika UI
42
DSP - Fisika UI
43
MATLAB Example 11
• Generate the complex-valued signal
x[n] = e[−0.1+j0.3]n, −10 ≤ n ≤ 10
• and plot its magnitude, phase, the real part, and the imaginary part in four separate
subplots.
DSP - Fisika UI
44
MATLAB Example 11
x[n] = e[−0.1+j0.3]n, −10 ≤ n ≤ 10
real part imaginary part
2 1
0.5
1
-0.5
-1
-1
-2
-1.5
-3 -2
-10 -8 -6 -4 -2 0 2 4 6 8 10 -10 -8 -6 -4 -2 0 2 4 6 8 10
n n
150
2.5
100
2
50
1.5 0
-50
1
-100
0.5
-150
0 -200
-10 -8 -6 -4 -2 0 2 4 6 8 10 -10 -8 -6 -4 -2 0 2 4 6 8 10
n n
DSP - Fisika UI
45
Discrete-Time Sinusoidal
• Basis for Fourier transform and in system theory as a basis for steady-state
analysis
=x [ n ] A cos (ωo n + θ o )
( t ) A cos ( Ωot + θo )
xa =
DSP - Fisika UI
46
Periodicity in time
• the sinusoidal sequence is periodic if
x [ n=
+ N ] A cos (ωo n + ωo N= + θo ) x [ n]
+ θ ) A cos (ωo n=
DSP - Fisika UI
47
DSP - Fisika UI
48
xe [ − n ] =xe [ n ]
xo [ − n ] =− xo [ n ]
DSP - Fisika UI
49
x [ n ] xe [ n ] + xo [ n ]
=
1 1
[ n] x [ n] + x [ −n]
xe= [ n] x [ n] − x [ −n]
xo=
2 2
DSP - Fisika UI
50
DSP - Fisika UI
51
MATLAB Example
• Let x[n] = u[n] − u[n − 10].
• Decompose x[n] into even and odd components.
DSP - Fisika UI
52
MATLAB Example 12
• Let x[n] = u[n] − u[n − 10].
• Decompose x[n] into even and odd components.
• The sequence x[n], which is nonzero over 0 ≤ n ≤ 9, is called a rectangular pulse
DSP - Fisika UI
53
MATLAB Example 12
• Let x[n] = u[n] − u[n − 10].
• Decompose x[n] into even and odd components.
• The sequence x[n], which is nonzero over 0 ≤ n ≤ 9, is called a rectangular pulse
Rectangular pulse
0.5
x(n)
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Even Part
0.5
xe(n)
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Odd Part
0.5
0
xe(n)
-0.5
-10 -8 -6 -4 -2 0 2 4 6 8 10
DSP - Fisika UI
54
• The convergence and expression for the sum of this series are used in many
applications
DSP - Fisika UI
55
Correlations of sequences
• Measure of the degree to which two sequences are similar
• the crosscorrelation of x[n] and y[n] is a sequence rxy[l] defined as
∞
=rxy [ ] ∑ x [ n] y [ n − ]
n = −∞
DSP - Fisika UI
56
Terima Kasih
Adhi Harmoko Saputro
DSP - Fisika UI