You are on page 1of 3

PROGRAM:

clc; clear all; close all;


fp=input('Enter PassBand Frequency');
fs=input('Enter StopBand Frequency');
rp=input('Enter PassBand Ripple');
rs=input('Enter StopBand Ripple');
f=input('Enter Frequency');
num=(-20*log10(sqrt(rp*rs)))-13;
den=(14.6*(fs-fp))/f;
N=ceil(num/den);
wp=2*fp/f; ws=2*fs/f;
wn=wp;
b=fir1(N,wn,hann(N+1));
figure(1);
freqz(b,1,256);
title('LPF Filter-Hanning window');
wn=ws;
b=fir1(N,wn,'high',hann(N+1));
figure(2);
freqz(b,1,256);
title('HPF Filter-Hanning window');
wn=[wp ws];
b=fir1(N,wn,'band',hann(N+1));
figure(3);
freqz(b,1,256);
title('BPF Filter-Hanning window');
wn=[wp ws];
b=fir1(N,wn,'stop',hann(N+1));
figure(4);
freqz(b,1,256);
title('BSF Filter-Hanning window');
OBSERVATION:
Enter PassBand Frequency 1000
Enter StopBand Frequency2000
Enter PassBand Ripple0.05
Enter StopBand Ripple0.04
Enter Frequency10000

LPF Filter-Hanning window

Magnitude (dB)

-50

-100

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency (
rad/sample)

0.9

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency (
rad/sample)

0.9

Phase (degrees)

0
-100
-200
-300
-400
-500

HPF Filter-Hanning window

Magnitude (dB)

50

-50

-100

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency ( rad/sample)

0.9

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency ( rad/sample)

0.9

Phase (degrees)

400
200
0
-200
-400
-600

BPF Filter-Hanning window

Magnitude (dB)

50

-50

-100

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency ( rad/sample)

0.9

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency ( rad/sample)

0.9

Phase (degrees)

0
-200
-400
-600
-800

BSF Filter-Hanning window

Magnitude (dB)

-2

-4

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency ( rad/sample)

0.9

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency ( rad/sample)

0.9

Phase (degrees)

0
-200
-400
-600
-800
-1000

You might also like