Professional Documents
Culture Documents
clear all;
N = 4; % Order of filter
wc = 0.45; % Cut Off frequency
[b,a] = butter(N,wc);
[H,W]=freqz(b,a,256);
hh=length(H);
f=1:hh;
figure(1);
plot(f/hh,20*log10(abs(H)),'linewidth',2);
[y,t] = impz(b,a,21);
stem(t,y);
clear all;
N = 4; % Order of filter
wc = 0.45; % Cut Off frequency
[b,a] = butter(N,wc);
[H,W]=freqz(b,a,256);
hh=length(H);
f=1:hh;
figure(1);
plot(f/hh,abs(H),'linewidth',2);
axis([0 1 -.1 1.1]);
zplane(b,a)
HPF
clear all;
N = 4; % Order of filter
wc = 0.25; % Cut Off frequency
[b,a] = butter(N,wc,'HIGH');
[H,W]=freqz(b,a,256);
hh=length(H);
f=1:hh;
figure(1);
plot(f/hh,abs(H),'linewidth',2);
clear all;
N = 4; % Order of filter
wc = 0.45; % Cut Off frequency
[b,a] = butter(N,wc,'HIGH');
[H,W]=freqz(b,a,256);
hh=length(H);
f=1:hh;
figure(1);
plot(f/hh,abs(H),'linewidth',2);
axis([0 1 -.1 1.1]);
zplane(b,a)
clear all;
N = 4; % Order of filter
wc = 0.45; % Cut Off frequency
[b,a] = butter(N,wc,'HIGH');
[H,W]=freqz(b,a,256);
hh=length(H);
f=1:hh;
figure(1);
plot(f/hh,20*log10(abs(H)),'linewidth',2);
[y,t] = impz(b,a,21);
stem(t,y);
BPF
m=[1 1 1 1 1 0 0 0 0 0];
f=[0 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 1.0];
[b,a]=yulewalk(10,f,m);
[h,w]=freqz(b,a,256);
plot(f,m,w/pi,abs(h),'--','linewidth',2)
legend('Ideal','yulewalk Designed')
title('Comparison of Frequency Response Magnitudes')
xlabel('Normalized Frequency')
ylabel('Magnitude Response')
grid on
zplane(b,a)
HPF
m=[0 0 1 1 1 1 1 1 1 1];
f=[0 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 1.0];
[b,a]=yulewalk(10,f,m);
[h,w]=freqz(b,a,256);
plot(f,m,w/pi,abs(h),'--','linewidth',2)
legend('Ideal','yulewalk Designed')
title('Comparison of Frequency Response
Magnitudes')
xlabel('Normalized Frequency')
ylabel('Magnitude Response')
grid on
m=[0 0 1 1 1 1 1 1 1 1];
f=[0 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 1.0];
[b,a]=yulewalk(10,f,m);
[h,w]=freqz(b,a,256);
plot(f,m,w/pi,abs(h),'--','linewidth',2)
legend('Ideal','yulewalk Designed')
title('Comparison of Frequency Response
Magnitudes')
xlabel('Normalized Frequency')
ylabel('Magnitude Response')
grid on
zplane (b,a)
BPF
Metode Windowing
LPF
HPF
BPF
clear all
clc
fs=2000;
t=0:1/(2*fs):0.05;
N=length(t);
a= 1* sin( 2* pi* 200 * t);
a1= 0.25* sin( 2* pi* 600 * t);
jumlah=a+a1;
figure(1)
subplot(311)
plot(t,a)
subplot(312)
plot(t,a1)
subplot(313)
plot(t,jumlah)
%=====================================%
N1= 4;
wc = 0.45;
[b,c] = butter(N1,wc);
output=filter(b,c,jumlah);
figure(10)
plot(t,output)
gauss=randn(1,N);
var= 0.2;
mean=0.0;
WGN = mean + (var * gauss);
figure(3)
subplot(211)
plot(t,WGN)
title('Noise x VAR ')
jumlah2= a + WGN;
subplot(212)
plot(t,jumlah2)
title('Sinyal penjumlahan Noise dan Sinyal awal')
N1= 4;
wc = 0.45;
[b,c] = butter(N1,wc);
output1=filter(b,c,jumlah2);
figure(4)
plot(t,output1)
%=================================%
1
0
-1
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
0.045
0.05
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
0.045
0.05
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
0.045
0.05
0.5
0
-0.5
1
0
-1
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
0.045
0.05
Noise x VAR
0.5
0
-0.5
-1
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
0.045
0.05
0.045
0.05
2
1
0
-1
-2
0.005
0.01
0.015
0.02
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
1.5
0.5
-0.5
-1
-1.5
0.025
0.03
0.035
0.04
0.045
0.05
clear all
clc;
[y,Fs] =wavread('a.wav');
y_mono=y(:,1);
y_resample=resample(y_mono,10000,22050);
figure(1);
subplot(311);
plot(y_mono);
N=length(y_mono);
var=0.2;
noise=var*randn(N,1);
subplot(312);
plot(noise);
%subplot(313);
%plot(y_resample);
hasil=(y_mono+noise);
subplot(313);
plot(hasil);
t=0:1/10000:0.1;
figure(2)
a=fft(hasil);
plot(a)
%FILTER%
N1= 4;
wc = 0.45;
[b,c] = butter(N1,wc);
output=filter(b,c,hasil);
figure(10)
plot(output)
0.5
0
-0.5
10
12
4
x 10
1
0
-1
10
12
4
x 10
1
0
-1
10
12
4
x 10
1
0
-1
10
12
4
x 10
500
0
-500
-250
-200
-150
-100
-50
50
100
150
200
250
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
10
12
4
x 10