AIM:
To verify response of analog LPF & 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:
% 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-->');
RESULT:
2 comments:
Hello please help me in following logic:-(
I have the filter H(z)=(1-z1*z-1)(1-z2*z-1)...(1-zN*z-1)
Where Z1,z2,...zN are the roots of the filter...
I need to implement this filter ....
It may be simple or complicated but pls give an idea:_(
The FIR filter I am using takes only zeros which are unimodular...
I'll give a hint...
the filter H(Z) can be represented in time domain as cascaded filter of indivisual filters each having roots z_n (n=1,2,3,...N) i.e
h(n)= (d(n)-z1*d(n-1))output cascaded with (d(n)-z2*d(n-1)).....output cascaded with(d(n)-zN*d(n-1))
Thus I have the matlab program written for every FIR filter with varying roots length
let Y(n) be the final output for given x(n) input
example:-say we have 3 roots z1,z2,z3 then
z1=1.000;z2=1.000;z3=1.000
then y1(n)=x(n)-z1*x(n-1);1st cascaded output
y2(n)=y1(n)-z2*y1(n-1);2nd cascaded output
Y(n)=y2(n)-z3*y2(n-1);final output
Is same as filter in direct form representation given x(n) as input and Direct form filter is polynomial representation of roots.
Y(n)= 1.0000 -3.0000 - 0.0000i 3.0000 + 0.0000i -1.0000 - 0.0000i
for impuse inputx(n)
Task is to generalize this code... Please help.... I will be awaiting at your response its too urgent,...
thanks for the code dude.i am impressed with your site having lot of matlab codes.
Post a Comment