Maximize stopband attenuation of a linear phase lowpass FIR filter
n = 10;
wpass = 0.12*pi;
wstop = 0.24*pi;
max_pass_ripple = 1;
N = 30*n;
w = linspace(0,pi,N);
A = [ones(N,1) 2*cos(kron(w',[1:n]))];
ind = find((0 <= w) & (w <= wpass));
Lp = 10^(-max_pass_ripple/20)*ones(length(ind),1);
Up = 10^(max_pass_ripple/20)*ones(length(ind),1);
Ap = A(ind,:);
ind = find((wstop <= w) & (w <= pi));
As = A(ind,:);
cvx_begin
variable h(n+1,1);
minimize( max( abs( As*h ) ) )
subject to
Lp <= Ap*h;
Ap*h <= Up;
cvx_end
disp(['Problem is ' cvx_status])
if ~strfind(cvx_status,'Solved')
return
else
fprintf(1,'The minimum attenuation in the stopband is %3.2f dB.\n\n',...
20*log10(cvx_optval));
h = [flipud(h(2:end)); h];
end
figure(1)
plot([0:2*n],h','o',[0:2*n],h','b:')
xlabel('t'), ylabel('h(t)')
figure(2)
H = exp(-j*kron(w',[0:2*n]))*h;
subplot(2,1,1)
plot(w,20*log10(abs(H)),...
[0 wpass],[max_pass_ripple max_pass_ripple],'r--',...
[0 wpass],[-max_pass_ripple -max_pass_ripple],'r--');
axis([0,pi,-50,10])
xlabel('w'), ylabel('mag H(w) in dB')
subplot(2,1,2)
plot(w,angle(H))
axis([0,pi,-pi,pi])
xlabel('w'), ylabel('phase H(w)')
Calling sedumi: 528 variables, 12 equality constraints
For improved efficiency, sedumi is solving the dual problem.
------------------------------------------------------------
SeDuMi 1.21 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 12, order n = 529, dim = 529, blocks = 229
nnz(A) = 3528 + 0, nnz(ADA) = 144, nnz(L) = 78
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 1.99E+02 0.000
1 : -1.99E-01 1.11E+02 0.000 0.5599 0.9000 0.9000 8.15 1 1 5.6E+01
2 : -1.16E-01 3.86E+01 0.000 0.3470 0.9000 0.9000 4.89 1 1 6.8E+00
3 : -4.46E-02 2.30E+01 0.000 0.5951 0.9000 0.9000 3.30 1 1 2.0E+00
4 : -2.97E-02 1.61E+01 0.000 0.7026 0.9000 0.9000 2.43 1 1 1.1E+00
5 : -2.12E-02 8.21E+00 0.000 0.5089 0.9000 0.9000 1.82 1 1 4.8E-01
6 : -1.91E-02 4.11E+00 0.000 0.5005 0.9000 0.9000 1.28 1 1 2.3E-01
7 : -1.77E-02 1.25E+00 0.000 0.3048 0.9000 0.9000 1.13 1 1 6.6E-02
8 : -1.75E-02 3.96E-01 0.000 0.3165 0.9000 0.9000 1.03 1 1 2.1E-02
9 : -1.75E-02 8.68E-02 0.000 0.2190 0.9074 0.9000 1.01 1 1 4.7E-03
10 : -1.75E-02 1.64E-02 0.000 0.1885 0.9063 0.9000 1.00 1 1 9.1E-04
11 : -1.75E-02 1.63E-03 0.000 0.0999 0.9092 0.9000 1.00 1 1 9.7E-05
12 : -1.75E-02 1.88E-06 0.093 0.0011 0.9990 0.8122 1.00 1 1 5.2E-07
13 : -1.75E-02 4.76E-11 0.273 0.0000 1.0000 1.0000 1.00 1 1 1.3E-11
iter seconds digits c*x b*y
13 0.1 Inf -1.7476196634e-02 -1.7476196631e-02
|Ax-b| = 6.9e-12, [Ay-c]_+ = 4.2E-12, |x|= 6.1e-01, |y|= 3.1e-01
Detailed timing (sec)
Pre IPM Post
0.000E+00 7.000E-02 1.000E-02
Max-norms: ||b||=1, ||c|| = 1.122018e+00,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.418.
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +0.0174762
Problem is Solved
The minimum attenuation in the stopband is -35.15 dB.