%% Bandpass Chebyshev Type I Filter
% Design a 20th-order Chebyshev Type I bandpass filter with a lower passband frequency of 500 Hz and a higher passband frequency of 560 Hz. Specify a passband ripple of 3 dB and a sample rate of 1500 Hz. Use the state-space representation. Design an identical filter using designfilt.

[A,B,C,D] = cheby1(10,3,[500 560]/750);
d = designfilt('bandpassiir','FilterOrder',20, ...
    'PassbandFrequency1',500,'PassbandFrequency2',560, ...
    'PassbandRipple',3,'SampleRate',1500);

%
% Convert the state-space representation to second-order sections. Visualize the frequency responses using fvtool.

sos = ss2sos(A,B,C,D);
fvt = fvtool(sos,d,'Fs',1500);
legend(fvt,'cheby1','designfilt')

% Copyright 2015 The MathWorks, Inc.