Escolar Documentos
Profissional Documentos
Cultura Documentos
03411640000011
ADD C
TUGAS FILTER
High Pass
Script Penjelasan
clc, clear all, close all
%% Filter parameters:
L = N+1; % filter length
n_h = (-(L-1)/2:(L-1)/2);
% hideal = (2*fc/Fs)*sinc(2*fc/Fs*n_h);
% Ideal Lowpass Filter
hideal = (-2*fc/Fs)*sinc(2*fc/Fs*n_h); %
Ideal Highpass Filter Persamaan ideal untuk high pass
% hideal(ceil(L/2)) = (pi- filter
2*pi*fc/Fs)/pi; % Untuk Highpass. Kalo
tidak di off kan saja
% h = kaiser(L,10)' .* hideal; % h is
our filter
h = hideal; %This non-windowed filter
will results Gibbs Phenomenon
n_h2=0:L-1;
figure(1),subplot(3,2,5:6),plot(n_h2,h),
xlabel('Time (samples)'),
Plotting hasil high pass filter tanpa
ylabel('Amplitude') window
title(['Impulse Response of '
num2str(fc) 'Hz Lowpass filter (without
Window) L = ' num2str(L)])
y2_conv=ifft(HY,N2);
t2_conv = 0:1/Fs:(N2-1)*(1/Fs);
figure(1),subplot(3,2,2), plot(t,y),
%axis(ax2)
hold on,plot(t2_conv,y2_conv)
legend('Origin','Filtered (conv)')
y2_kali=ifft(YH,N2);
t2_kali = 0:1/Fs:(N2-1)*(1/Fs);
figure(1),subplot(3,2,4),plot(t,y),
hold on,
plot(t2_kali,y2_kali),%axis(ax2)
legend('Origin','Filtered (kali)')
%% Built-in MATLAB Filter (without zero Membuat filter tanpa zero padding
padding)
%% fir1
Wn = (2/Fs)*fc;
b = fir1(N,Wn,'low',kaiser(N+1,3));
y_fir1 = filter(b,1,y);
%% fdesign.lowpass
fp = 2*fc/Fs; Membuat filter desain
d=fdesign.lowpass('Fp,Fst,Ap,Ast',fp-
0.01,fp+0.01,2,60);
designmethods(d);
Hd=design(d,'equiripple');
y_fdesignlow =filter(Hd,y);
figure(100), subplot(2,1,1)
set(gcf,'Units','Normalized','OuterPosit
ion',[0 0.04 0.5 0.96])
plot(t,y_fir1),hold on,
plot(t,y_fdesignlow)
title('Without Zero Padding'),
legend('fir1','fdesign.lowpass')
%% Removing delay Menghilangkan delay
% grpdelay(firf,N,Fs)
delay = mean(grpdelay(Hd));
t_fdesignlow2=t(1:end-floor(delay));
y_fdesignlow2=y_fdesignlow(floor(delay)+
1:end);
figure(101),subplot(2,1,1)
set(gcf,'Units','Normalized','OuterPosit
ion',[0.5 0.04 0.5 0.96])
plot(t_fdesignlow2,y_fdesignlow2,t,y_fde
signlow)
title('fdesign.lowpass : Without Zero
Padding'), legend('Moved delay','Still
delayed')
%% Built-in MATLAB Filter (with zero Membuat filter dengan zero padding
padding)
nol=zeros(size(y));
ypad=[nol y nol];
%% fir1
Wn = (2/Fs)*fc;
b = fir1(N,Wn,'low',kaiser(N+1,3));
y_fir1 = filter(b,1,ypad);
Low Pass
Script Penjelasan
%% Filter parameters:
L = N+1; % filter length
n_h = (-(L-1)/2:(L-1)/2);
hideal = (2*fc/Fs)*sinc(2*fc/Fs*n_h); %
Ideal Lowpass Filter
% hideal = (-2*fc/Fs)*sinc(2*fc/Fs*n_h);
% Ideal Highpass Filter
% hideal(ceil(L/2)) = (pi-
2*pi*fc/Fs)/pi; % Untuk Highpass. Kalo Persamaan ideal untuk high pass
tidak di off kan saja
filter
% h = kaiser(L,10)' .* hideal; % h is
our filter
h = hideal; %This non-windowed filter
will results Gibbs Phenomenon
n_h2=0:L-1;
figure(1),subplot(3,2,5:6),plot(n_h2,h),
xlabel('Time (samples)'),
ylabel('Amplitude')
title(['Impulse Response of ' Plotting hasil low pass filter tanpa
num2str(fc) 'Hz Lowpass filter (without window
Window) L = ' num2str(L)])
Gambar 2.
Gambar 3.
Gambar 4.
Gambar 5.
Pada gambar-gambar diatas dapat diketahui bahwa sinyal yang difilter adalah yang frekuensinya
tinggi.
Low Pass
Gambar 6.
Gambar 7.
Gambar 8.
Gambar 9.
Gambar 10.
Pada gambar-gambar diatas dapat diketahui bahwa sinyal yang difilter adalah yang frekuensinya
rendah.