%% Design Constrained Least Squares Filter
% Design a constrained least squares filter with a nonnegative zero-phase response, and then use the firminphase function to compute the minimum-phase spectral factor.

f   = [0 0.4 0.8 1];
a   = [0 1 0];
up  = [0.02 1.02  0.01];
lo  = [0 0.98 0]; % The zeros ensure nonnegative zero-phase resp.
n   = 32;
b   = fircls(n,f,a,up,lo);
h   = firminphase(b)

% Copyright 2012 The MathWorks, Inc.