% Kurt Sanner
% Elec 301 Group Project
% December 15, 1999
% invcheby.m


% This file creates an inverse Chebyshev filter
% the filter is a lowpass filter with the following properties:
%  Maximum decibel decrease at the passband is 2 decibels
%  The passband passband 2 decibel decrese is set at 17kHz
%  Minimum decibel decrease in the stopband is 50kHz
%  The stopband 50decibel decese is set at 22kHz
% The inverse Chebyshev filter that results will be a ninth order filter.
% Although this filter will not be cheap, it is assumed to be used
% In a recording studio for optimal performance requirements.
format long g;
w=0:20*2*pi:25000*2*pi;
Gp = 2;
Gs = 50;
Wp = 2*pi*18000;
Ws = 2*pi*22000;
[n, Wc] = cheb2ord (Wp, Ws, Gp, Gs, 's');
[num, den] = cheby2 (n, Gs, Wc, 's');
[MAG, PHASE] = bode(num, den, w);

%This allows us to plot on a frequency scale of Hz
w = w/(2*pi);

% first, plot the magnitude response of the filter
plot (w, MAG);
xlabel ('frequency in Hz');
ylabel ('magnitude of the frequency response');
title ('frequency response for an inverse Chebyshev filter');

pause;

% Next, plot the bode plot for the filter
bode(num, den);

