Tuesday 15 March 2011

Matlab filters

AIM:
To verify response of analog Low pass filter (LPF) & High pass filter(HPF) using MATLAB


 
EQUIPMENTS:

Operating System         – Windows XP
Constructor                  - Simulator
Software                      - CCStudio 3 & MATLAB 7.5


THEORY:

Analog Low pass filter & High pass filter are obtained by using butterworth or chebyshev filter with coefficients are given. The frequency – magnitude plot gives the frequency response of the filter.

PROGRAM:
 
Matlab code for filters

%  IIR filters LPF & HPF
clc;
clear all;
close all;
warning off;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
c=input('enter choice of filter 1. LPF 2. HPF \n ');
if(c==1)
    disp('Frequency response of  IIR LPF is:');
[b,a]=butter(n,wn,'low','s');
end
if(c==2)
    disp('Frequency response of  IIR HPF is:');
[b,a]=butter(n,wn,'high','s');
end
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure,subplot(2,1,1);plot(om/pi,m);
title('magnitude response of  IIR filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
subplot(2,1,2);plot(om/pi,an);
title('phase response of  IIR filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');


 

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...