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

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING


COMPUTER ENGINEERING DEPARTMENT

Digital Signal Processing

Lab Manual No 12

Filter Design using MATLAB

Course Instructor:
Dr. Muhammad Majid

Semester:
Autumn 2015

Digital Signal Processing Lab Instructor:-Engr. Aamir Arsalan


Session:-2013 Computer
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT

Objectives:-

The objective of this lab is to understand the filter design using MATLAB.

Procedure:-

Filters are a basic component of all signal processing and telecommunication system. A filter is
a device or process that removes some unwanted components or features from a signal. Filtering
is a class of signal processing used to complete or partial suppression of some aspects of the
signal. Most often, this means to remove some frequencies and not others in order to suppress the
interfacing signals and reduce the background noise.

Types of Filters:-

In signal processing, the filters can be of four types, i.e. Lowpass Filters, Highpass Filter,
Bandpass Filters, and Bandstop Filters.

Infinite Impulse Response (IIR) Filters:-

Another type of filter is the Infinite Impulse Response (IIR) filter and the Impulse Response of
an IIR filter is of infinite duration. The IIR filters have the feedback, due to which they are also
known as Recursive filters. The general difference for an IIR filter is:

Where "ak" is the k-th feedback tap. The left "" denoted the summation from k =1 to k =N-1,
"N" is the number of the feedback taps in the IIR filter. The right "" denotes the summation
from k = 0 to k = M 1, where "M" is the number of feedforward taps.

We have given the codes for IIR filter design using Butterworth, Chebeshev Type I, Chebeshev
Type II and Elliptic Filters.

IIR Butterworth Low pass Filter:-

%IIR Butterworth Lowpass Filter:


%A MATLAB program to design IIR Butterworth Lowpass Filter
clf; %Clear all figures

Digital Signal Processing Lab Instructor:-Engr. Aamir Arsalan


Session:-2013 Computer
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT

clear all; %Clear all variables


close all; %Close all figures
n = 6; %Define the order of the filter
fc = input('Enter the cutoff frequency');
fs = input('Enter the sampling frequency');
Wc = 2 * fc / fs; %Normalizing the frequencies
[b,a]=butter(n,Wc,'low'); %Calculation of filter coefficients
freqz(b,a,fs); %Plotting the filter response
title('Magnitude and Phase response of Butterworth IIR Lowpass
filter');

IIR Chebyshev Type I Filter:-

%IIR Chebyshev-Type-1 Lowpass Filter:


%A MATLAB program to design IIR Chebyshev Type I Lowpass Filter
clf; %Clear all figures
clear all; %Clear all variables
close all; %Close all figures
n = 6; %Define the order of the filter
R = 0.5; %Define the Passband peak-to-peak ripple in decibels
fc = input('Enter the cutoff frequency');
fs = input('Enter the sampling frequency');
Wc = 2 * fc / fs; %Normalizing the frequencies
[b,a]=cheby1(n,R,Wc,'low'); %Calculating filter coefficients
freqz(b,a,fs); %Plotting the filter response
title('Magnitude and Phase Response of Chebyshev-Type-1 IIR
Lowpass Filter');

IIR Chebyshev Type II Filter:-

%IIR Chebyshev-Type-2 Lowpass Filter:


%A MATLAB program to design IIR Chebyshev Type II Lowpass Filter
clf; %Clear all figures
clear all; %Clear all variables
close all; %Close all figures
n = 6; %Define the order of the filter
R = 20; %Stopband ripple in decibles
fc = input('Enter the cutoff frequency');
fs = input('Enter the sampling frequency');
Wc = 2 * fc / fs; %Normalizing the frequencies
[b,a]=cheby2(n,R,Wc,'low');%Calculation of filter coefficients
freqz(b,a,fs); %Plotting the filter response

Digital Signal Processing Lab Instructor:-Engr. Aamir Arsalan


Session:-2013 Computer
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT

title('Magnitude and Phase Response of Chebyshev-Type-2 IIR


Lowpass Filter');

IIR Elliptic Low pass Filter:-

%IIR Elliptic Lowpass Filter:


%A MATLAB program to design IIR Elliptic Lowpass Filter
clf; %Clear all figures
clear all; %Clear all variables
close all; %Close all figures
n = 6; %Define the order of the filter
Rp=10; %Passband Ripple in decibels
Rs = 20; %Stopband ripple in decibles
fc = input('Enter the cutoff frequency');
fs = input('Enter the sampling frequency');
Wc = 2 * fc / fs; %Normalizing the frequencies
[b,a]=ellip(n,Rp,Rs,Wc,'low');%Calculation of filter
coefficients
freqz(b,a,fs); %Plotting the filter response
title('Magnitude and Phase Response of Elliptic IIR Lowpass
Filter');

Lab Tasks:-

1. Run all the above codes and analyze the magnitude and
phase spectrum of the filter designed.
2. Calculate the Zero, poles and gain of the filter designed
and comment about the filter stability and causality.
3. Write a MATLAB program to design a Highpass IIR filter
using Butterworth, Chebychev Type_1, and Chebychev Type_2
methods. Use your own values. Compare the Magnitude and
Phase Response of the three by plotting them on the same
plot.

Digital Signal Processing Lab Instructor:-Engr. Aamir Arsalan


Session:-2013 Computer

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