7.3 1. Listing

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

7.

1. Listing
h=[-4,1,-1,-2,5,6,5,-2,-1,1,-4];
M=length(h); n=0:M-1;
[Hr,w,a,L]=Hr_Type1(h);
amax=max(a)+1;amin=min(a)-1;
subplot(2,2,1);stem(n,h);axis([-1 2*L+1 amin amax])
xlabel('n');ylabel('h(n)');title('Impulse Response')
subplot(2,2,3);stem(0:L,a);axis([-1 2*L+1 amin amax])
xlabel('n');ylabel('a(n)');title('a(n)coefficients')
subplot(2,2,2);plot(w/pi,Hr);grid
xlabel('frequency in pi units');ylabel('Hr')
title('Type-1 Amplitude Response')
subplot(2,2,4);zplane(h,1)

2. Tampilan

Gambar 1. Tampilan solusi dari MATLAB untuk FIR fasa linier tipe 1

Gambar 2. Tampilan grafik FIR fasa linier tipe 1

3. Analisa

7.4
1. Listing
h=[-4,1,-1,-2,5,6,6,5,-2,-1,1,-4];
M=length(h); n=0:M-1;
[Hr,w,b,L]=Hr_Type2(h);
b,L
bmax=max(b)+1;bmin=min(b)-1;
subplot(2,2,1);stem(n,h);axis([-1 2*L+1 bmin bmax])
xlabel('n');ylabel('h(n)');title('Impulse Response')
subplot(2,2,3);stem(1:L,b);axis([-1 2*L+1 bmin bmax])
xlabel('n');ylabel('b(n)');title('b(n)coefficients')
subplot(2,2,2);plot(w/pi,Hr);grid
xlabel('frequency in pi units');ylabel('Hr')
title('Type-2 Amplitude Response')
subplot(2,2,4);zplane(h,1)

2. Tampilan

Gambar 3. Tampilan solusi dari MATLAB untuk FIR fasa linier tipe 2

Gambar 4. Tampilan grafik FIR fasa linier tipe 2

7.5
1. Listing
h=[-4,1,-1,-2,5,6,5,-2,-1,1,-4];
M=length(h); n=0:M-1;
[Hr,w,c,L]=Hr_Type3(h);
c,L
cmax=max(c)+1;cmin=min(c)-1;
subplot(2,2,1);stem(n,h);axis([-1 2*L+1 cmin cmax])
xlabel('n');ylabel('h(n)');title('Impulse Response')
subplot(2,2,3);stem(0:L,c);axis([-1 2*L+1 cmin cmax])
xlabel('n');ylabel('c(n)');title('c(n)coefficients')
subplot(2,2,2);plot(w/pi,Hr);grid
xlabel('frequency in pi units');ylabel('Hr')
title('Type-3 Amplitude Response')
subplot(2,2,4);zplane(h,1)

2. Tampilan

Gambar 5. Tampilan solusi dari MATLAB untuk FIR fasa linier tipe 3

Gambar 6. Tampilan grafik FIR fasa linier tipe 3

7.6
1. Listing
h=[-4,1,-1,-2,5,6,5,-2,-1,1,-4];
M=length(h); n=0:M-1;
[Hr,w,d,L]=Hr_Type4(h);
d,L
dmax=max(d)+1;dmin=min(d)-1;
subplot(2,2,1);stem(n,h);axis([-1 2*L+1 dmin dmax])
xlabel('n');ylabel('h(n)');title('Impulse Response')
subplot(2,2,3);stem(1:L,d);axis([-1 2*L+1 dmin dmax])
xlabel('n');ylabel('d(n)');title('d(n)coefficients')
subplot(2,2,2);plot(w/pi,Hr);grid
xlabel('frequency in pi units');ylabel('Hr')
title('Type-4 Amplitude Response')
subplot(2,2,4);zplane(h,1)

2. Tampilan

Gambar 7. Tampilan solusi dari MATLAB untuk FIR fasa linier tipe 4

Gambar 8. Tampilan grafik FIR fasa linier tipe 4

7.7
1. Listing
wp = 0.2*pi; ws = 0.3*pi; tr_width = ws - wp;
M = ceil(6.6*pi/tr_width) + 1
n=[0:1:M-1];
wc = (ws+wp)/2, % Ideal LPF cutoff frequency
hd = ideal_lp(wc,M); w_ham = (hamming(M))'; h = hd .* w_ham;
[db,mag,pha,grd,w] = freqz_m(h,[1]); delta_w = 2*pi/1000;
Rp = -(min(db(1:1:wp/delta_w+1))); % Actual Passband Ripple
Rp = 0.0394
As = -round(max(db(ws/delta_w+1:1:501))) % Min Stopband
attenuation
As = 52
% plots
subplot(2,2,1); stem(n,hd); title('Ideal Impulse Response')
axis([0 M-1 -0.1 0.3]); xlabel('n'); ylabel('hd(n)')
subplot(2,2,2); stem(n,w_ham);title('Hamming Window')
axis([0 M-1 0 1.1]); xlabel('n'); ylabel('w(n)')
subplot(2,2,3); stem(n,h);title('Actual Impulse Response')
axis([0 M-1 -0.1 0.3]); xlabel('n'); ylabel('h(n)')
subplot(2,2,4); plot(w/pi,db);title('Magnitude Response in
dB');grid
axis([0 1 -100 10]); xlabel('frequency in pi units');
ylabel('Decibels')

2. Tampilan

Gambar 9. Tampilan lowpass dengan metode hamming window


7.8
1. Listing
wp = 0.2*pi; ws = 0.3*pi; As = 50; tr_width = ws - wp;
M = ceil((As-7.95)/(2.285*tr_width)+1) + 1
M = 61
n=[0:1:M-1]; beta = 0.1102*(As-8.7)
beta = 4.5513
wc = (ws+wp)/2; hd = ideal_lp(wc,M);
w_kai = (kaiser(M,beta))'; h = hd .* w_kai;
[db,mag,pha,grd,w] = freqz_m(h,[1]); delta_w = 2*pi/1000;
As = -round(max(db(ws/delta_w+1:1:501))) % Min Stopband
Attenuation
subplot(2,2,1); stem(n,hd); title('Ideal Impulse Response')
axis([0 M-1 -0.1 0.3]); xlabel('n'); ylabel('hd(n)')
subplot(2,2,2); stem(n,w_kai);title('Kaiser Window')
axis([0 M-1 0 1.1]); xlabel('n'); ylabel('w(n)')
subplot(2,2,3); stem(n,h);title('Actual Impulse Response')
axis([0 M-1 -0.1 0.3]); xlabel('n'); ylabel('h(n)')
subplot(2,2,4);plot(w/pi,db);title('Magnitude Response in
dB');grid
axis([0 1 -100 10]); xlabel('frequency in pi units');
ylabel('Decibels')ylabel('Decibels')

2. Tampilan
Gambar 10. Plot Lowpass dengan kaiser window
7.9
1. Listing
ws1 = 0.2*pi; wp1 = 0.35*pi; wp2 = 0.65*pi;
ws2 = 0.8*pi;
tr_width = min((wp1-ws1),(ws2-wp2));
M = ceil(11*pi/tr_width) + 1
n=[0:1:M-1]; wc1 = (ws1+wp1)/2; wc2 = (wp2+ws2)/2;
hd = ideal_lp(wc2,M) - ideal_lp(wc1,M);
w_bla = (blackman(M))'; h = hd .* w_bla;
[db,mag,pha,grd,w] = freqz_m(h,[1]); delta_w = 2*pi/1000;
Rp = -min(db(wp1/delta_w+1:1:wp2/delta_w)) % Actua; Passband
Ripple
Rp = 0.0030
As = -round(max(db(ws2/delta_w+1:1:501))) % Min Stopband
Attenuation
subplot(2,2,1); stem(n,hd); title('Ideal Impulse Response')
axis([0 M-1 -0.4 0.5]); xlabel('n'); ylabel('hd(n)')
subplot(2,2,2); stem(n,w_bla);title('Blackman Window')
axis([0 M-1 0 1.1]); xlabel('n'); ylabel('w(n)')
subplot(2,2,3); stem(n,h);title('Actual Impulse Response')
axis([0 M-1 -0.4 0.5]); xlabel('n'); ylabel('h(n)')
subplot(2,2,4);plot(w/pi,db);axis([0 1 -150 10]);
title('Magnitude Response in dB');grid;
xlabel('frequency in pi units'); ylabel('Decibels')

2. Tampilan
Gambar 11. Plot bandpass filter dengan blackman window

7.10
1. Listing
M = 45; As = 60; n=[0:1:M-1];
beta = 0.1102*(As-8.7)
beta = 5.6533
w_kai = (kaiser(M,beta))'; wc1 = pi/3; wc2 = 2*pi/3;
hd = ideal_lp(wc1,M) + ideal_lp(pi,M) - ideal_lp(wc2,M);
h = hd .* w_kai; [db,mag,pha,grd,w] = freqz_m(h,[1]);
subplot(2,2,1); stem(n,hd); title('Ideal Impulse Response')
axis([-1 M -0.2 0.8]); xlabel('n'); ylabel('hd(n)')
subplot(2,2,2); stem(n,w_kai);title('Kaiser Window')
axis([-1 M 0 1.1]); xlabel('n'); ylabel('w(n)')
subplot(2,2,3); stem(n,h);title('Actual Impulse Response')
axis([-1 M -0.2 0.8]); xlabel('n'); ylabel('h(n)')
subplot(2,2,4);plot(w/pi,db); axis([0 1 -80 10]);
title('Magnitude Response in dB');grid;
xlabel('frequency in pi units'); ylabel('Decibels')
2. Tampilan

Gambar 12. Tampilan bandstop dengn kaiser window

7.11
1. Listing
M = 25; alpha = (M-1)/2; n = 0:M-1;
hd = (2/pi)*((sin((pi/2)*(n-alpha)).^2)./(n-alpha));
hd(alpha+1)=0;
w_han = (hann(M))'; h = hd .* w_han; [Hr,w,P,L] =
Hr_Type3(h);
subplot(2,2,1); stem(n,hd); title('Ideal Impulse Response')
axis([-1 M -1.2 1.2]); xlabel('n'); ylabel('hd(n)')
subplot(2,2,2); stem(n,w_han);title('Hann Window')
axis([-1 M 0 1.2]); xlabel('n'); ylabel('w(n)')
subplot(2,2,3); stem(n,h);title('Actual Impulse Response')
axis([-1 M -1.2 1.2]); xlabel('n'); ylabel('h(n)')
w = w'; Hr = Hr';
w = [-fliplr(w), w(2:501)]; Hr = [-fliplr(Hr), Hr(2:501)];
subplot(2,2,4);plot(w/pi,Hr); title('Amplitude
Response');grid;
xlabel('frequency in pi units'); ylabel('Hr');
axis([-1 1 -1.1 1.1]);

2. Tampilan

Gambar 13. Transformasi Hilbert pada FIR latihan 7.11


7.12
1. Listing
M = 20; alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l;
Hrs = [1,1,1,zeros(1,15),1,1]; %Ideal Amp Res sampled
Hdr = [1,1,0,0]; wdl = [0,0.25,0.25,1]; %Ideal Amp Res for
plotting
k1 = 0:floor((M-1)/2); k2 = floor((M-1)/2)+1:M-1;
angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)];
H = Hrs.*exp(j*angH); h = real(ifft(H,M));
[db,mag,pha,grd,w] = freqz_m(h,1); [Hr,ww,a,L] =
Hr_Type2(h);
subplot(2,2,1);plot(wl(1:11)/pi,Hrs(1:11),'o',wdl,Hdr);
axis([0,1,-0.1,1.1]); title('Frequency Samples: M=20')
xlabel('frequency in pi units'); ylabel('Hr(k)')
subplot(2,2,2); stem(l,h); axis([-1,M,-0.1,0.3])
title('Impulse Response'); xlabel('n'); ylabel('h(n)');
subplot(2,2,3); plot(ww/pi,Hr,wl(1:11)/pi,Hrs(1:11),'o');
axis([0,1,-0.2,1.2]); title('Amplitude Response')
xlabel('frequency in pi units'); ylabel('Hr(w)')
subplot(2,2,4);plot(w/pi,db); axis([0,1,-60,10]); grid
title('Magnitude Response'); xlabel('frequency in pi
units');
ylabel('Decibels');

2. Tampilan
Gambar 14. Metode desain sampling frekuensi Naive
7.13
1. Listing
% T1 = 0.5 dan T2=0.39
M = 40; alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l;
Hrs = [ones(1,5),0.5,zeros(1,29),0.5,ones(1,4)];
Hdr = [1,1,0,0]; wdl = [0,0.25,0.25,1]; %Ideal Amp Res for
plotting
k1 = 0:floor((M-1)/2); k2 = floor((M-1)/2)+1:M-1;
angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)];
H = Hrs.*exp(j*angH);
h = real(ifft(H,M));
[db,mag,pha,grd,w] = freqz_m(h,1); [Hr,ww,a,L] =
Hr_Type2(h);
subplot(2,2,1);plot(wl(1:11)/pi,Hrs(1:11),'o',wdl,Hdr);
axis([0,1,-0.1,1.1]); title('Frequency Samples: M=20')
xlabel('frequency in pi units'); ylabel('Hr(k)')
subplot(2,2,2); stem(l,h); axis([-1,M,-0.1,0.3])
title('Impulse Response'); xlabel('n'); ylabel('h(n)');
subplot(2,2,3); plot(ww/pi,Hr,wl(1:11)/pi,Hrs(1:11),'o');
axis([0,1,-0.2,1.2]); title('Amplitude Response')
xlabel('frequency in pi units'); ylabel('Hr(w)')
subplot(2,2,4);plot(w/pi,db); axis([0,1,-90,10]); grid
title('Magnitude Response'); xlabel('frequency in pi
units');
ylabel('Decibels');

2. Tampilan
Gambar 15. Desain frekuensi optimum T1=0,5

Gambar 16. Desain frekuensi optimum T2=0,39

You might also like