0% found this document useful (0 votes)
24 views3 pages

Rectangle

The program designs four different types of filters - low pass, high pass, band pass, and band stop - based on user-specified passband frequency, stopband frequency, passband ripple, and stopband ripple. It calculates the number of filter coefficients, designs the filters using FIR filtering with a rectangular window, and plots the magnitude and phase response of each filter.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Rectangle

The program designs four different types of filters - low pass, high pass, band pass, and band stop - based on user-specified passband frequency, stopband frequency, passband ripple, and stopband ripple. It calculates the number of filter coefficients, designs the filters using FIR filtering with a rectangular window, and plots the magnitude and phase response of each filter.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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,boxcar(N+1));
figure(1);
freqz(b,1,256);
title('LPF Filter-Rectangular window');
wn=ws;
b=fir1(N,wn,'high',boxcar(N+1));
figure(2);
freqz(b,1,256);
title('HPF Filter-Rectangular window');
wn=[wp ws];
b=fir1(N,wn,'band',boxcar(N+1));
figure(3);
freqz(b,1,256);
title('BPF Filter-Rectangular window');
wn=[wp ws];
b=fir1(N,wn,'stop',boxcar(N+1));
figure(4);
freqz(b,1,256);
title('BSF Filter-Rectangular window');

OBSERVATION:
Enter PassBand Frequency 1000
Enter StopBand Frequency2000
Enter PassBand Ripple0.05
Enter StopBand Ripple0.04
Enter Frequency10000

LPF Filter-Rectangular 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)

-100

-200

-300

HPF Filter-Rectangular window

Magnitude (dB)

20
0
-20
-40
-60

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)

200
0
-200
-400
-600

BPF Filter-Rectangular 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

300

Phase (degrees)

200
100
0
-100
-200

BSF Filter-Rectangular window

Magnitude (dB)

-10

-20

-30

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