%% Constrained Least-Squares Lowpass Filter
% Design a 150th-order lowpass filter with a normalized cutoff frequency of 0.4\pi rad/sample. Specify a maximum absolute error of 0.02 in the passband and 0.01 in the stopband. Display plots of the bands.

n = 150;
f = [0 0.4 1];
a = [1 0];
up = [1.02 0.01];
lo = [0.98 -0.01];
b = fircls(n,f,a,up,lo,'both');

%
% The Bound Violations denote the iterations of the procedure as the design converges. Display the magnitude response of the filter.

fvtool(b)

% Copyright 2015 The MathWorks, Inc.