You are on page 1of 3

%prak&1.

m
m=[0 0 1 1 0 0 1 1 0 0];
f=[0 0. 1 0.2 0. 3 0. 4 0. 5 0. 6 0. 7 0.8 1];
B=remez(50,f,m);
[H,wT]=freqz(B,[1],100);
plot(f,mwT/pi,abs(H))
title('Filter FIR dengan dua Passband')
xlabel('Normalisasi frekuensi')
ylabel('respon amplitudo')

%file fls.m
function b=fls(n,f,m)
L=length(f);
if m(L)==0;
b=zeros(1,n)
else
b=[zeros(1,(n-1)/2),m(L),zeros(1,(n-1)/2)];
end
while L>2
b=b+(m(L-2)-m(L-1))*fls(n,f(L-2),f(L-1));
L=L-2;
end

%file flsp.m
function b=flsp(n,f1,f2,p)
if nargin < 4, p=0.31*n*(f2-f1);
end;
w0=pi*(f2+f1)/2;
dw=pi*(f2-f1)/2;
if rem(n,2)==0, nx=[1/2:(n-1)/2];
else, nx=[1:(n-1)/2];
end;
M=length(nx);
h=(sin(w0*nx))./(pi*nx);
if dw~=0 & p~=0;
wd=(dw/p)*nx;
wt=(sin(wd)./wd).^p;
h=wt.*h;
end;
if rem (n,2)==0,
b=[h(M:-1:1),h];
else
b=[h(M:-1:1),wo/pi,h];
end;

f=[0 0.2 0.4 0.6 0.8 1];


m=[1 1 1 1 0 0];
b=fls(51,f,m);
[h,w]=freqz(b,1,512);
subplot(221);
plot(w/pi,abs(h),'-r')
title('N=51');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')
b= fls (101,f,m);
[h,w]=freqz(b,1,512);
subplot(222);
plot(w/pi,abs(h),'-r')
title('N=101');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

b= fls (501,f,m);
[h,w]=freqz(b,1,512);
subplot(223);
plot(w/pi,abs(h),'-r')
title('N=501');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

b= fls (51,f,m);
[h,w]=freqz(b,1,512);
subplot(224);
plot(w/pi,abs(h),'-r')
title('N=1001');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

f=[0 0.2 0.4 0.6 0.8 1];


m=[1 1 1 1 0 0];
B=remez(50,f,m);
[H,wT]=freqz(B,[1],100);
plot (f,m,wT/pi,abs(H))
title('Filter FIR dengan dua PassBand');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

f=[0 0.2 0.24 0.5 0.55 0.7 0.73 0.85 0.9 1];
m=[0 0 0.7 0.7 0.5 0.5 0 0 1 1];
b= fls (51,f,m);
[h,w]=freqz(b,1,512);
subplot(221);
plot(w/pi,abs(h),'-r')
title('N=51');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

b= fls (101,f,m);
[h,w]=freqz(b,1,512);
subplot(222);
plot(w/pi,abs(h),'-r')
title('N=101');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

b= fls (501,f,m);
[h,w]=freqz(b,1,512);
subplot(223);
plot(w/pi,abs(h),'-r')
title('N=501');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

b= fls (1001,f,m);
[h,w]=freqz(b,1,512);
subplot(224);
plot(w/pi,abs(h),'-r')
title('N=1001');
xlabel('normalisasi frequensi')
ylabel('respon amplitudo')

You might also like