Вы находитесь на странице: 1из 8

4.

LowPass Orde 8 dengan FC 500

close all;

Fsampling = 4000; % Sampling frequency


T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t);
%-----------------FIR Digital Filter (Fcutoff HPF 500 Hz)-------------
b0=0.0179;b1=0.0485;b2=0.1226;b3=0.1970;b4=0.2279;b5=0.1970;
b6=0.1226;b7=0.0485;b8=0.0179;
x7=0;x6=0;x5=0;x4=0;x3=0;x2=0;x1=0;x0=0;
for i=1:L
x8=x7;
x7=x6;
x6=x5;
x5=x4;
x4=x3;
x3=x2;
x2=x1;
x1=x0;
x0=x(i);
y=b0*x0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6...
+ b7*x7 + b8*x8;
yfilter(i)=y;
end
y = yfilter';
%-----------------Fast Fourier Transform (FFT) ----------------------
n = 2^nextpow2(L);
Yfft_x = fft(x,n);
P2_x = abs(Yfft_x/L);
P1_x = P2_x(1:n/2+1);
P1_x(1:end-1) = 2*P1_x(1:end-1);

Yfft = fft(y,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
subplot(2,2,1); plot(t,x);
title ('Sinyal Sebelum LowPass Orde8 FC500');
subplot(2,2,2); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1_x(1:n/2));
title ('FFT Sebelum LowPass Orde8 FC500');
subplot(2,2,3); plot(t,y);
title ('Sinyal Sesudah LowPass Orde8 FC500');
subplot(2,2,4); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('FFT Sesudah LowPass Orde8 FC500');
Grafik LowPass Orde 8 dengan FC 500
BandPass Orde 8 dengan FC 50 dan 200

close all;

Fsampling = 4000; % Sampling frequency


T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t);
%-----------------FIR Digital Filter (Fcutoff HPF 500 Hz)-------------
b0=0.0138;b1=0.0444;b2=0.1254;b3=0.2148;b4=0.2537;b5=0.2148;
b6=0.1254;b7=0.0444;b8=0.0138;

x7=0;x6=0;x5=0;x4=0;x3=0;x2=0;x1=0;x0=0;
for i=1:L
x8=x7;
x7=x6;
x6=x5;
x5=x4;
x4=x3;
x3=x2;
x2=x1;
x1=x0;
x0=x(i);
y=b0*x0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6...
+ b7*x7 + b8*x8;
yfilter(i)=y;
end
y = yfilter';
%-----------------Fast Fourier Transform (FFT) ----------------------
n = 2^nextpow2(L);
Yfft_x = fft(x,n);
P2_x = abs(Yfft_x/L);
P1_x = P2_x(1:n/2+1);
P1_x(1:end-1) = 2*P1_x(1:end-1);

Yfft = fft(y,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
subplot(2,2,1); plot(t,x);
title ('Sinyal Sebelum BandPass Orde8 FC50&200');
subplot(2,2,2); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1_x(1:n/2));
title ('FFT Sebelum BandPass Orde8 FC50&200');
subplot(2,2,3); plot(t,y);
title ('Sinyal Sesudah BandPass Orde8 FC50&200');
subplot(2,2,4); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('FFT Sesudah BandPass Orde8 FC50&200');
Grafik BandPass Orde 8 dengan FC 50 dan 200

4.2

High Pass Orde 20 FC 500


close all;

Fsampling = 4000; % Sampling frequency


T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t);
%-----------------FIR Digital Filter (Fcutoff HPF 500 Hz)-------------
b0=-0.0026;b1=-0.0026;b2=-0.0000;b3=0.0087;b4=0.0212;b5=0.0244;
b6=-0.0000;b7=-0.0609;b8=-0.1455;b9=-0.2205;b10=0.7518;b11=-0.2205;
b12=-0.1455;b13=-0.0609;b14=-0.0000;b15=0.0244;b16=0.0212;b17=0.0087;
b18=-0.0000;b19=-0.0026;b20=-0.0026;
x16=0;x17=0;x18=0;x19=0;
x8=0;x9=0;x10=0;x11=0;x12=0;x13=0;x14=0;x15=0;
x7=0;x6=0;x5=0;x4=0;x3=0;x2=0;x1=0;x0=0;
for i=1:L
x20=x19;
x19=x18;
x18=x17;
x17=x16;
x16=x15;
x15=x14;
x14=x13;
x13=x12;
x12=x11;
x11=x10;
x10=x9;
x9=x8;
x8=x7;
x7=x6;
x6=x5;
x5=x4;
x4=x3;
x3=x2;
x2=x1;
x1=x0;
x0=x(i);
y=b0*x0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6...
+ b7*x7 + b8*x8+ b9*x9 + b10*x10+ b11*x11 + b12*x12+ b13*x13 + b14*x14...
+ b15*x15 + b16*x16+ b17*x17 + b18*x18+ b19*x19+ b20*x20;
yfilter(i)=y;
end
y = yfilter';
%-----------------Fast Fourier Transform (FFT) ----------------------
n = 2^nextpow2(L);
Yfft_x = fft(x,n);
P2_x = abs(Yfft_x/L);
P1_x = P2_x(1:n/2+1);
P1_x(1:end-1) = 2*P1_x(1:end-1);

Yfft = fft(y,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
subplot(2,2,1); plot(t,x);
title ('Sinyal Sebelum HIGHPass Orde 20 FC500');
subplot(2,2,2); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1_x(1:n/2));
title ('FFT Sebelum HIGHPass Orde 20 FC500');
subplot(2,2,3); plot(t,y);
title ('Sinyal Sesudah HIGHPass Orde 20 FC500');
subplot(2,2,4); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('FFT Sesudah HIGHPass Orde 20 FC500');
Grafik LowPass Orde 20 dengan FC 500

BandPass Orde 20 dengan FC 50 dan 200


close all;

Fsampling = 4000; % Sampling frequency


T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t);
%-----------------FIR Digital Filter (Fcutoff HPF 500 Hz)-------------
b0=-0.0036;b1=-0.0025;b2=0.0000;b3=0.0071;b4=0.0211;b5=0.0426;
b6=0.0700;b7=0.0994;b8=0.1258;b9=0.1441;b10=0.1506;b11=0.1441;
b12=0.1258;b13=0.0994;b14=0.0700;b15=0.0426;b16=0.0211;b17=0.0071;
b18=0.0000;b19=-0.0025;b20=-0.0036;
x16=0;x17=0;x18=0;x19=0;
x8=0;x9=0;x10=0;x11=0;x12=0;x13=0;x14=0;x15=0;
x7=0;x6=0;x5=0;x4=0;x3=0;x2=0;x1=0;x0=0;
for i=1:L
x20=x19;
x19=x18;
x18=x17;
x17=x16;
x16=x15;
x15=x14;
x14=x13;
x13=x12;
x12=x11;
x11=x10;
x10=x9;
x9=x8;
x8=x7;
x7=x6;
x6=x5;
x5=x4;
x4=x3;
x3=x2;
x2=x1;
x1=x0;
x0=x(i);
y=b0*x0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6...
+ b7*x7 + b8*x8+ b9*x9 + b10*x10+ b11*x11 + b12*x12+ b13*x13 + b14*x14...
+ b15*x15 + b16*x16+ b17*x17 + b18*x18+ b19*x19+ b20*x20;
yfilter(i)=y;
end
y = yfilter';
%-----------------Fast Fourier Transform (FFT) ----------------------
n = 2^nextpow2(L);
Yfft_x = fft(x,n);
P2_x = abs(Yfft_x/L);
P1_x = P2_x(1:n/2+1);
P1_x(1:end-1) = 2*P1_x(1:end-1);

Yfft = fft(y,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
subplot(2,2,1); plot(t,x);
title ('Sinyal Sebelum BandPass Orde20 FC50&200');
subplot(2,2,2); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1_x(1:n/2));
title ('FFT Sebelum BandPass Orde20 FC50&200');
subplot(2,2,3); plot(t,y);
title ('Sinyal Sesudah BandPass Orde20 FC50&200');
subplot(2,2,4); plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('FFT Sesudah BnadPass Orde20 FC50&200');
Grafik BandPass Orde 20 dengan FC 50 dan 200

Вам также может понравиться