%% Lowpass Elliptic Filter Order
% For 1000 Hz data, design a lowpass filter with less than 3 dB of ripple in the passband, defined from 0 to 40 Hz, and at least 60 dB of ripple in the stopband, defined from 150 Hz to the Nyquist frequency, 500 Hz. Find the filter order and cutoff frequency.

Wp = 40/500;
Ws = 150/500;
Rp = 3;
Rs = 60;
[n,Wp] = ellipord(Wp,Ws,Rp,Rs)

%
% Specify the filter in terms of second-order sections and plot the frequency response.

[z,p,k] = ellip(n,Rp,Rs,Wp);
sos = zp2sos(z,p,k);
freqz(sos,512,1000)
title(sprintf('n = %d Elliptic Lowpass Filter',n))

% Copyright 2015 The MathWorks, Inc.