%% Filter design using firceqrip
% Design a 30th order FIR filter using firceqrip.

b = firceqrip(30,0.4,[0.05 0.03]); fvtool(b)

%
% Design a minimum order FIR filter using firceqrip. The passband edge and stopband edge frequencies are 0.35\pi and 0.45\pi rad/sample. The allowed deviations are 0.02 and 1e-4.

b = firceqrip('minorder',[0.35 0.45],[0.02 1e-4]); fvtool(b)

%
% Design a 30th order FIR filter with the stopedge keyword to define the response at the edge of the filter stopband.

b = firceqrip(30,0.4,[0.05 0.03],'stopedge'); fvtool(b)

%
% Design a 30th order FIR filter with the slope keyword and r = 20.

b = firceqrip(30,0.4,[0.05 0.03],'slope',20,'stopedge'); fvtool(b)

%
% Design a 30th order FIR filter defining the stopband and specifying that the resulting filter is minimum phase with the min keyword.

b = firceqrip(30,0.4,[0.05 0.03],'stopedge','min'); fvtool(b)

% Comparing this filter to the filter in Figure 1. The cutoff frequency wo = 0.4 now applies to the edge of the stopband rather than the point at which the frequency response magnitude is 0.5.
%
% Viewing the zero-pole plot shown here reveals this is a minimum phase FIR filter - the zeros lie on or inside the unit circle, z = 1

fvtool(b,'polezero')

%
% Design a 30th order FIR filter with the invsinc keyword to shape the filter passband with an inverse sinc function.

b = firceqrip(30,0.4,[0.05 0.03],'invsinc',[2 1.5]); fvtool(b)

% The inverse sinc function being applied is defined as 1/sinc(2*w)^1.5.