EXPERIMENT - 2


AIM

To demonstrate various types of Filters made with butterworth Filter based on Frequency Response.

THEORY

Types of Filter on basis of frequency response
  1. Low-pass filter – low frequencies are passed, high frequencies are attenuated.
  2. High-pass filter – high frequencies are passed, low frequencies are attenuated.
  3. Band-pass filter – only frequencies in a frequency band are passed.
  4. Band-stop filter – only frequencies in a frequency band are attenuated.

The Butterworth filter is a type of signal processing filter designed to have as flat a frequency response as possible in the passband. It is also referred to as a maximally flat magnitude filter.

MATLAB COMMANDS USED

* [b a]=butter(order,[W1 W2],'filter type');
* [H,w]=freqz(b,a);

MATLAB CODE

%Butterworth filter type
clear all;
%Low pass Filter
[b_low a_low]=butter(3,.3,'low');
[H_low,w_low]=freqz(b_low,a_low);
subplot(2,2,1);
plot(w_low/pi,abs(H_low),'black','linewidth'
,2,'linesmoothing','on');
title('Magnitude response of a 3rd order Low pass
butterworth filter with Wc at .3');
xlabel('Normalized frequency');
ylabel('Gain');
axis([0 1 0 1.1]);


%high pass Filter
[b_high a_high]=butter(3,.6,'high');
[H_high,w_high]=freqz(b_high,a_high);
subplot(2,2,2);
plot(w_high/pi,abs(H_high),'black','linewidth',2
,'linesmoothing','on');
title('Magnitude response of a 3rd order High pass
butterworth filter with Wc at .6');
xlabel('Normalized frequency');
ylabel('Gain');
axis([0 1 0 1.1]);


%band pass Filter
[b_pass a_pass]=butter(3,[.3 .7],'bandpass');
[H_pass,w_pass]=freqz(b_pass,a_pass);
subplot(2,2,3);
plot(w_pass/pi,abs(H_pass),'black','linewidth',
2,'linesmoothing','on');
title('Magnitude response of a 3rd order Band pass
butterworth filter with edges at .3 and .7');
xlabel('Normalized frequency');
ylabel('Gain');
axis([0 1 0 1.1]);


%Band stop Filter
[b_stop a_stop]=butter(3,[.3 .8],'stop');
[H_stop,w_stop]=freqz(b_stop,a_stop);
subplot(2,2,4);
plot(w_stop/pi,abs(H_stop),'black','linewidth',2,
'linesmoothing','on');
title('Magnitude response of a 3rd order 
Band stop butterworth filter with band 
edges at .3 and .8');
xlabel('Normalized frequency');
ylabel('Gain');
axis([0 1 0 1.1]);

%print('filtertypes','-dpng');