Signals and Systems - Electrical Engineering

(avery) #1
11.4 IIR Filter Design 677

11.4.5 General IIR Filter Design with MATLAB


The following functionbuttercheby1can be used to design low-pass, high-pass, band-pass, and stop-
band Butterworth as well as Chebyshev filters. One important thing to remember when designing
band-pass and band-stop filters is that the order of the low-pass prototype is half that of the desired
filter.

function [b,a,H,w] = buttercheby1(lporder,wn,BC,type)
%
% Design of frequency discriminating filters
% using Butterworth and Chebyshev methods, the bilinear transformation and
% frequency transformations
%
% lporder : order of low-pass filter prototype
% wn : vector containing the cut-off normalized frequency(ies)
% (entries must be normalized)
% BC: Butterworth (0) or Chebyshev1 (1)
% type : type of filter desired
% 1 = low-pass
% 2 = high-pass
% 3 = band-pass
% 4 = stopband
% [b,a] : numerator, denominator coefficients of designed filter
% [H,w] : frequency response, frequency range
% USE:
% [b,a,H,w] = buttercheby1(lporder,wn,BC,type)
if BC == 0; % Butterworth filter
if type == 1
[b,a] = butter(lporder,wn); % lowpas
elseif type == 2
[b,a] = butter(lporder,wn,‘high’); % high-pass
elseif type == 3
[b,a] = butter(lporder,wn); % band-pass
else
[b,a] = butter(lporder,wn,‘stop’); % stopband
end
[H,w] = freqz(b,a,256);
else % Chebyshev1 filter
R = 0.01;
if type == 1,
[b,a] = cheby1(lporder,R,wn); % lowpas
elseif type == 2,
[b,a] = cheby1(lporder,R,wn,‘high’); % high-pass
elseif type == 3,
[b,a] = cheby1(lporder,R,wn); % band-pass
else
Free download pdf