Chebyshev FIR Filter Design in MATLAB
Chebyshev FIR Filter Design in MATLAB
THEORY:
In signal processing, a finite impulse response (FIR) filter is a
filter whose impulse response is of finite duration, because it settles to
zero in finite time.
The impulse response of an Nth-order discrete-time FIR filter lasts
exactly N + 1 sample before it then settles to zero.FIR filters can be
discrete-time or continuous-time, and digital or analog.
If an FIR filter is non-causal, the range of nonzero values in its impulse
response can start before n = 0, with the defining formula appropriately
generalized.
An FIR filter has a number of useful properties which sometimes make it
preferable to an infinite impulse response (IIR) filter. FIR filters:
Require no feedback. This means that any rounding errors are not
compounded by summed iterations.
PROCEDURE:
To start MATLAB, double-click the MATLAB shortcut
Click on new script .An editor window appears type the program
code in editor window
Save the program code by clicking the save option save the file
name with .m extension
Run the program using the run option icon
Errors if present appear in command window
PROGRAM:
clc;
close all;
clear all;
rp=input('enter the pass band ripple...');
rs=input('enter the stop band ripple...');
fs=input('enter the stop band frequency..');
fp=input('enter the pass band frequency....');
f=input('enter the sampling frequency...');
r=input('enter the ripple value in dB...');
wp=2*fp/f;
ws=2*fs/f;
num=20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
if(rem(n,2)==0)
n=n+1;
end
y=chebwin(n,r);
%low pass filter
b=fir1(n-1,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
ylabel('gain in db,,,>');
xlabel('(a) normalised frequency...>');
title('low pass filter');
%high pass filter
b=fir1(n-1,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
ylabel('gainin dB...>');
xlabel('(b)normalized frequency...>');
title('high pass filter');
%band pass filter
wn=[wp,ws];
b=fir1(n-1,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('gainin dB...>');
xlabel('(c)normalized frequency...>');
title('band pass filter');
%band stop filter
b=fir1(n-1,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(b));
subplot(2,2,4);
plot(o/pi,m);
ylabel('gainin dB...>');
xlabel('(d)normalised freqz...>');
title('stop band filter');
RESULT:
enter the pass band ripple...0.03
enter the stop band ripple...0.02
enter the stop band frequency..2400
enter the pass band frequency....1800
enter the sampling frequency...10000
enter the ripple value in dB...40
The fir of chebshev LPF,HPF,BPF,BSF was simulated using matlab
Hence taken stop band frequency is 2400
pass band frequency is 1800
normalized stopband frequency=2(fs/f)
=(2(2400))/10000
=0.48
Normalized passband frequency=2(fp/f)
=0.36
We observed the normalized cutoff frequencies in the filter output
response.