Bab 2a
Sinyal-sinyal Waktu Diskrit
Kuliah PSD 01 (MFS4617)
agfi@ugm.ac.id
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 2
Sinyal Waktu Diskrit
• Kategori sinyal:
– Sinyal
analog
x
a(t)
t bisa sembarang besaran fisik apapun
untuk PSD dianggap sebagai besaran waktu (detik);
– Sinyal
digital
x(n)
n
merupakan bilangan bulat yang
menyatakan instan diskrit dalam waktu
sinyal waktu-diskrit
;
• Tanda panah ke-atas
cuplikan saat n=0;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 3
Macam-macam Deret:
1. Deret Cuplik satuan –
unit sample
• Fungsi
zeros(1,N)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 4
Macam-macam Deret:
1. Deret Cuplik satuan –
unit sample
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 5
Macam-macam Deret:
2. Deret Langkah Satuan –
unit step
• Fungsi
ones(1,N)
digunakan untuk
menghasilkan sebuah
vektor baris dengan
data satu (‘1’)
sebanyak N;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 6
Macam-macam Deret:
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 7
Macam-macam Deret:
3. Deret Eksponensial Nilai-Real –
Real-valued exponential
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 8
Macam-macam Deret:
3. Deret Eksponensial Nilai-Real –
Real-valued exponential
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 9
Macam-macam Deret:
4. Deret Eksponensial Nilai-Kompleks –
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 10
Macam-macam Deret:
4. Deret Eksponensial Nilai-Kompleks –
Complex-valued exponential
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 11
Macam-macam Deret:
5. Deret Sinusoidal
•
:
merupakan fase
dalam radian;
• Untuk implementasi
deret…
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 12
Macam-macam Deret:
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 13
Macam-macam Deret:
6. Deret Acak
• Dicirikan dengan
–
Probability
Density Function;
• Menggunakan
rand(1,N)
:
– Deret acak dengan panjang N terdistribusi
merata (
uniformly distributed
) antara 0-1;
• Menggunakan
randn(1,N)
:
– Deret acak Gaussian dengan rerata 0 dan
varians 1;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 14
Macam-macam Deret:
6. Deret Acak
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 15
Macam-macam Deret:
7. Deret Periodik
• Sebuah deret
dikatakan periodik jika
n
N
n
x
n
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 16
Macam-macam Deret:
7. Deret Periodik
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 17
Operasi Deret:
1-Penjumlahan sinyal
function [y,n] = sigadd(x1,n1,x2,n2) % implements y(n) = x1(n)+x2(n) % ---% [y,n] = sigadd(x1,n1,x2,n2)
% y = sum sequence over n, which includes n1 and n2 % x1 = first sequence over n1
% x2 = second sequence over n2 (n2 can be different from n1) %
n = min(min(n1),min(n2)):max(max(n1),max(n2)); % duration of y(n) y1 = zeros(1,length(n)); y2 = y1; % initialization
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1; % x1 with duration of y y2(find((n>=min(n2))&(n<=max(n2))==1))=x2; % x2 with duration of y
y = y1+y2; % sequence addition
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 18
Operasi Deret:
2-Perkalian sinyal
function [y,n] = sigmult(x1,n1,x2,n2) % implements y(n) = x1(n)*x2(n) % ---% [y,n] = sigmult(x1,n1,x2,n2)
% y = product sequence over n, which includes n1 and n2 % x1 = first sequence over n1
% x2 = second sequence over n2 (n2 can be different from n1) %
n = min(min(n1),min(n2)):max(max(n1),max(n2)); % duration of y(n) y1 = zeros(1,length(n)); y2 = y1; %
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1; % x1 with duration of y y2(find((n>=min(n2))&(n<=max(n2))==1))=x2; % x2 with duration of y
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 19
Operasi Deret:
3-Penskalaan sinyal
• Masing-masing cuplikan dikalikan dengan suatu
konstanta;
• Menggunakan operator ‘
*
’ pada MATLAB;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 20
Operasi Deret:
4-Penggeseran sinyal
• Masing-masing cuplikan x(n) digeser sebanyak k
sehingga dihasilkan y(n)
y(n)={x(n-k)}
;
• Jika
m=n-k
n=m+k
y(m+k)={x(m)}
;
• Dengan demikian, operasi tidak berpengaruh pada
vektor x, tetapi vektor n berubah dengan menambahkan
nilai k pada masing-masing elemen:
function [y,n] = sigshift(x,m,n0)
% implements y(n) = x(n-n0)
%
---% [y,n] = sigshift(x,m,n0)
%
n = m+n0; y = x;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 21
Operasi Deret:
5-Pelipatan sinyal
• Pada operasi ini, tiap-tiap cuplikan dari x(n)
dilipat pada n=0
y(n) = {x(-n)};
• Untuk MATLAB digunakan bantuan fungsi
fliplr
untuk melipat x dan
–fliplr
untuk
melipat indeks-nya:
function [y,n] = sigfold(x,n)
% implements y(n) = x(-n)
%
---% [y,n] = sigfold(x,n)
%
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 22
Operasi Deret:
6-Penjumlahan cuplikan
• Operasi ini berbeda dengan penjumlahan sinyal,
karena yang dijumlahkan adalah tiap-tiap
elemen dalam x(n) (semuanya)
y(n):
• Gunakan
sum(x(n1:n2));
dalam MATLAB;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 23
Operasi Deret:
7-Perkalian cuplikan
• Operasi ini berbeda dengan perkalian sinyal,
karena yang dikalikan adalah tiap-tiap elemen
dalam x(n) (semuanya)
y(n):
• Gunakan
prod(x(n1:n2));
dalam MATLAB;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 24
Operasi Deret:
8-Energi Sinyal
• Tanda bintang pada x(n) merupakan tanda konjugasi
kompleks
perhatikan penempatan tandanya…
x
*(n)
konjugasi (
superscript
), MATLAB-nya:
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 25
Operasi Deret:
9-Daya Sinyal
• Daya rerata dari suatu sinyal periodik dengan
periode dasar N…
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 26
Contoh 2.1: Pertanyaan
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 27
Contoh 2.1: Jawaban (a)
n = [-5:5];
x = 2*impseq(-2,-5,5)-impseq(4,-5,5);
stem(n,x);
title('Sequence in Example 2.1a');
xlabel('n');
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 28
Contoh 2.1: Jawaban (a)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 29
Contoh 2.1: Jawaban (b)
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 Example 2.1b');
xlabel('n');
ylabel('x(n)');
axis([0,20,-1,11])
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 30
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 31
Contoh 2.1: Jawaban (c)
n = [0:50];
x = cos(0.04*pi*n)+0.2*randn(size(n));
stem(n,x);
title('Sequence in Example 2.1c');
xlabel('n');
ylabel('x(n)');
axis([0,50,-1.4,1.4])
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 32
Contoh 2.1: Jawaban (c)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 33
Contoh 2.1: Jawaban (d)
n=[-10:9];
x=[5,4,3,2,1];
xtilde=x' * ones(1,4);
xtilde=(xtilde(:))';
stem(n,xtilde);
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 34
Contoh 2.1: Jawaban (d)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 35
Contoh 2.1: Jawaban (a,b,c dan d)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 36
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 37
Contoh 2.2: Jawaban (a)
[x11,n11] = sigshift(x,n,5);
[x12,n12] = sigshift(x,n,-4);
[x1,n1] = sigadd(2*x11,n11,-3*x12,n12);
stem(n1,x1);
title('Sequence in Example 2.2a')
xlabel('n');
ylabel('x1(n)');
axis([min(n1)-1,max(n1)+1,min(x1)-1,max(x1)+1])
set(gca,'XTickMode','manual','XTick',[min(n1),0,max(
n1)])
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 38
Contoh 2.2: Jawaban (a)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 39
Contoh 2.2: Jawaban (b)
[x21,n21] = sigfold(x,n);
[x21,n21] = sigshift(x21,n21,3);
[x22,n22] = sigshift(x,n,2);
[x22,n22] = sigmult(x,n,x22,n22);
[x2,n2] = sigadd(x21,n21,x22,n22);
stem(n2,x2);
title('Sequence in Example 2.2b')
xlabel('n'); ylabel('x2(n)');
axis([min(n2)-1,max(n2)+1,0,40])
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 40
Contoh 2.2: Jawaban (b)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 41
Contoh 2.2: Jawaban (a dan b)
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 42
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 43
Contoh 2.3: Jawaban
n = [-10:1:10]; alpha = -0.1+0.3j;
x = exp(alpha*n);
subplot(2,2,1); stem(n,real(x));
title('real part');xlabel('n')
subplot(2,2,2); stem(n,imag(x));
title('imaginary part');xlabel('n')
subplot(2,2,3); stem(n,abs(x));
title('magnitude part');xlabel('n')
subplot(2,2,4); stem(n,(180/pi)*angle(x));
title('phase part');xlabel('n')
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 44
Contoh 2.3: Jawaban
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 45
Beberapa hasil Penting…
•
Sintesa cuplikan satuan (
unit
sample synthesis
)
sembarang deret x(n) dapat
disintesa sebagai jumlahan
deret cuplik satuan berbobot,
tertunda dan terskala
•
Sintesa ganjil & genap (
even
& odd synthesis
)
deret
bilangan-nyata x(n) dinamakan
genap (even) jika:
x
e(-n) = x
e(n)
•
Dinamakan ganjil (odd) jika:
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 46
Beberapa hasil Penting…
• Dengan demikian sembarang deret
x(n)
dapat di-dekomposisi menjadi komponen
genap dan ganjil:
x(n) = x
e
(n) + x
o
(n)
• dengan bagian genap dan ganjilnya:
x
e
(n) = ½ [x(n)+x(-n)]
x
o
(n) = ½ [x(n)-x(-n)]
• Matlabnya…
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 47
Beberapa hasil Penting…
function [xe, xo, m] = evenodd(x,n)
% Real signal decomposition into even and odd parts
%
---% [xe, xo, m] = evenodd(x,n)
%
if any(imag(x) ~= 0)
error('x is not a real sequence')
end
m = -fliplr(n);
m1 = min([m,n]); m2 = max([m,n]); m = m1:m2;
nm = n(1)-m(1); n1 = 1:length(n);
x1 = zeros(1,length(m));
x1(n1+nm) = x; x = x1;
xe = 0.5*(x + fliplr(x));
xo = 0.5*(x - fliplr(x));
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 48
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 49
Contoh 2.4: Jawaban
n = [0:10];
x = stepseq(0,0,10)-stepseq(10,0,10);
[xe,xo,m] = evenodd(x,n);
subplot(1,1,1)
subplot(2,2,1); stem(n,x);
title('Rectangular pulse')
xlabel('n'); ylabel('x(n)'); axis([-10,10,0,1.2])
subplot(2,2,2); stem(m,xe); title('Even Part')
xlabel('n'); ylabel('xe(n)'); axis([-10,10,0,1.2])
subplot(2,2,4); stem(m,xo); title('Odd Part')
xlabel('n'); ylabel('xe(n)');
axis([-10,10,-0.6,0.6])
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 50
Contoh 2.4: Jawaban
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 51
Beberapa hasil Penting…
•
Deret Geometrik
(
Geometric Series
)
deret eksponensial
satu-sisi dalam
bentuk {
J
n
, n
K
0},
dengan
J
merupakan
konstanta
sembarang;
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 52
Beberapa hasil Penting…
•
Korelasi Deret
(
correlations of
sequences
)
mengukur derajat
kesamaan dua deret;
• Definisi
kroskorelasi…
• Definisi
autokorelasi…
• Akan dibahas nanti…
agfi@ugm.ac.id II.A. Sinyal-sinyal Waktu Diskrit 53
Bersambung...
• Berikutnya...
Bab 2b
Sistem-sistem Waktu Diskrit,
Konvolusi dan Persamaan Beda
Kuliah PSD 01 (MFS4617)
agfi@ugm.ac.id
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
2
Pendahuluan
• Sistem diskrit
dinyatakan dengan
operator T[.] yang membawa deret x(n)
(eksitasi) menjadi deret lain y(n) (tanggap
atau
response
)
y(n) = T[x(n)];
• Sistem diskrit
sinyal masukan menjadi
sinyal keluaran;
• Sistem diskrit:
– Linear, dan
– Non-inear
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 3
Sistem Linear
prinsip
superposisi
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
4
Sistem Linear
Time-Invariant
•
Linear Time-Invariant
(LTI)
sistem yang pasangan masukan dan
keluarannya, x(n) dan y(n), tidak berubah terhadap penggeseran n:
•
Bisa juga dituliskan sebagai:
•
Tanggap impuls sistem dinyatakan oleh h(n)
penjumlahan
konvolusi linear:
•
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
5
Linear
Time-Invariant
•
Dengan demikian
sistem LTI dinyatakan dalam ranah waktu
melalui tanggap impuls-nya h(n):
•
Stabilitas
dikatakan stabil BIBO (input
Bounded-output):
•
atau jika tanggap impuls-nya dapat dijumlah secara absolut:
•
Kausalitas
untuk memastikan sistem dapat dibuat:
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 6
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
7
Solusi Contoh 2.5
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
8
Solusi Contoh 2.5
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 9
Solusi Contoh 2.5
n = -5:50;
u1 = stepseq(0,-5,50); u2=stepseq(10,-5,50); % input x(n)
x = u1-u2;
% impulse response h(n) h = ((0.9).^n).*u1; subplot(1,1,1)
subplot(2,1,1); stem(n,x); axis([-5,50,0,2]) title('Input Sequence')
xlabel('n'), ylabel('x(n)')
subplot(2,1,2); stem(n,h); axis([-5,50,0,2]) title('Impulse Response')
xlabel('n'), ylabel('h(n)'); pause % output response
y = (10*(1-(0.9).^(n+1))).*(u1-u2)+(10*(1-(0.9)^10)*(0.9).^(n-9)).*u2; subplot(1,1,1)
subplot(2,1,2); stem(n,y); axis([-5,50,0,8]) title('Output Sequence')
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
10
Solusi Contoh 2.5
-5 0 5 10 15 20 25 30 35 40 45 50
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
11
Solusi Contoh 2.5
-5 0 5 10 15 20 25 30 35 40 45 50
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 12
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
13
Konvolusi Grafis
% input x(n)
x = [3,11,7,0,-1,4,2]; nx = [-3:3];
% impulse response h(n)
h = [2,3,0,-5,2,1]; nh = [-1:4];
subplot(1,1,1)
% plot x(k) and h(k)
subplot(2,2,1); stem(nx-0.05,x); axis([-5,5,-6,12]);
hold on; stem(nh+0.05,h,':')
title('x(k) and h(k)');xlabel('k');
text(-0.5,11,'solid: x dashed: h'); hold off
% plot x(k) and h(-k)
subplot(2,2,2); stem(nx-0.05,x); axis([-5,5,-6,12]);
hold on; stem(-fliplr(nh)+0.05,fliplr(h),':')
title('x(k) and h(-k)');xlabel('k');
text(-0.5,-1,'n=0')
text(-0.5,11,'solid: x dashed: h'); hold off
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
14
Konvolusi Grafis
% plot x(k) and h(-1-k)
subplot(2,2,3); stem(nx-0.05,x); axis([-5,5,-6,12]);
hold on; stem(-fliplr(nh)+0.05-1,fliplr(h),':')
title('x(k) and h(-1-k)');xlabel('k');
text(-1.5,-1,'n=-1')
text(-0.5,11,'solid: x dashed: h'); hold off
% plot x(k) and h(2-k)
subplot(2,2,4); stem(nx-0.05,x); axis([-5,5,-6,12]);
hold on; stem(-fliplr(nh)+0.05+2,fliplr(h),':')
title('x(k) and h(2-k)');xlabel('k');
text(2-0.5,-1,'n=2')
text(-0.5,11,'solid: x dashed: h'); hold off
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 15
Solusi Contoh 2.6
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
16
Konvolusi: Implementasi MATLAB
• Menggunakan fungsi
conv()
;
• y = conv(x,h);
• Merujuk contoh 2.3:
– x = [3, 11, 7, 0, -1, 4, 2];
– h = [2, 3, 0, -5, 2, 1];
– y = conv(x,h);
• Perhatikan hasilnya…!
• Agar diperoleh informasi waktu (diskrit):
• Sehingga:
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
17
Konvolusi: Implementasi MATLAB
function [y,ny] = conv_m(x,nx,h,nh)
% Modified convolution routine for signal processing
%
---% [y,ny] = conv_m(x,nx,h,nh)
%
y = convolution result
% ny = support of y
%
x = first signal on support nx
% nx = support of x
%
h = second signal on support nh
% nh = support of h
%
nyb = nx(1)+nh(1); nye = nx(length(x)) + nh(length(h));
ny = [nyb:nye];
y = conv(x,h);
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 18
Contoh 2.7: Penggunaan conv_m()
untuk contoh 2.6
>> x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:
3];
>> h = [2, 3, 0, -5, 2, 1]; nh = [-1: 4];
>> [y,ny] = conv_m(x,nx,h,nh)
y =
6 31 47 6 -51 -5 41 18 -22 -3 8 2
ny =
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
19
Korelasi: ditinjau kembali
•
Kroskorelasi
r
yx
(l)
menggunakan
persamaan:
r
xy
(l) = y(l) * x(-l)
• Sedangkan
autokorelasi
r
xx
(l)
menggunakan persamaan:
r
xx
(l) = x(l) * x(-l)
• Perhatikan contoh 2.8 berikut…
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
20
Contoh 2.8
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 21
Solusi Contoh 2.8
>> x = [3, 11, 7, 0, -1, 4, 2]'; >> h = [2, 3, 0, -5, 2, 1]'; >> [y,H] = conv_tp(h,x)
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
22
Solusi Contoh 2.8
H =
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
23
Persamaan Beda
• Sebuah sistem LTI bisa dinyatakan melalui persamaan
beda:
• Jika
a
n#
0
maka persamaan bedanya ordenya N;
• Praktisnya dihitung secara maju (dari n=-
T
hingga +
T
),
sehingga:
• Penyelesaian persamaan ini dalam bentuk:
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 24
Persamaan Beda
• Bagian homogen dinyatakan dengan:
• Dengan z
k, k=1,…,N merupakan N akar dari persamaan
karakteristik:
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
25
Pers. Beda: Implementasi MATLAB
• Menggunakan fungsi
filter()
;
– y = filter(b,a,x);
• dengan
– b = [ b0, b1, …, bM];
– a = [a0, a1, …, aN];
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
26
Contoh 2.9
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 27
Solusi Contoh 2.9
% noise sequence 1
x = [3, 11, 7, 0, -1, 4, 2]; nx=[-3:3]; % given signal x(n) [y,ny] = sigshift(x,nx,2); % obtain x(n-2) w = randn(1,length(y)); nw = ny; % generate w(n) [y,ny] = sigadd(y,ny,w,nw); % obtain y(n)=x(n-2)+w(n) [x,nx] = sigfold(x,nx); % obtain x(-n) [rxy,nrxy] = conv_m(y,ny,x,nx); % cross-corrlation subplot(1,1,1)
subplot(2,1,1);stem(nrxy,rxy)
axis([-4,8,-50,250]);xlabel('lag variable l')
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
28
Solusi Contoh 2.9
% noise sequence 2
x = [3, 11, 7, 0, -1, 4, 2]; nx=[-3:3]; % given signal x(n)
axis([-4,8,-50,250]);xlabel('lag variable l')
ylabel('rxy');title('Crosscorrelation: noise sequence 2')
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
29
Solusi Contoh 2.9
-4 -2 0 2 4 6 8
lag variable l
rx
y
Crosscorrelation: noise sequence 1 Maximum
lag variable l
rx
y
Crosscorrelation: noise sequence 2
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 30
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
31
Contoh 2.10
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
32
Solusi Contoh 2.10
a=[1,-1,0.9];b=1;
%print -deps2 ex021000.eps %
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 33
Solusi Contoh 2.10
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
34
Solusi Contoh 2.10
ans =
14.8785
magz =
0.9487
0.9487
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
35
Tanggap Masukan-Nol dan
Kondisi-Nol
• Karena penyelesaian persamaan beda mulai dari n=0
(
forward
), maka diperlukan kondisi awal untuk x(n) dan
y(n) untuk menentukan keluaran untuk n
K
0, sehingga
persamaan beda dituliskan menjadi:
• dengan kondisi awal:
• Solusi persamaan (2.21) diperoleh dalam bentuk:
Zero-Input
solution Zero-State
solution x(n)
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, 36
Penapis Digital
• Penapis FIR (
Finite Impulse Response
) juga dinamakan
non-rekursif atau
moving average
(MA)
jika tanggap
impuls-nya berhingga, atau h(n)=0 untuk n < n
1dan n>
n
2(filter(b,1,x)):
• Penapis IIR (
Infinite Impulse Response
) juga dinamakan
rekursif (menggunakan keluaran sebelumnya) atau
agfi@ugm.ac.id II.B. Sistem Waktu Diskrit, Konvolusi dan PB
37