function [z,p,gain] = invcheby2 (ap,as,oms,opt) % INVCHEBY - Chebyshev type II analog lowpass filter prototype. % [z,p,gain] = invcheby2 (ap,as,oms,opt) returns the zeros, poles and gain % of an normalized prototype type II Chebyshev analog lowpass filter % with ap decibels of ripple in the passband, as decibels of ripple % in the stopband and oms is normalized frequency of the start of the % stopband. Type II Chebyshev filters are maximally flat in the passband. % opt=0 ... attenuation as is optimized on the start of the stopband % opt<>0 ... start of the stopband is optimized % % Author(s): M. Laipert, M. Vlcek, J. Vrbata % Programmed by Jan Vrbata, 1999-2000 % This is a version for GNU OCTAVE 2.0.4 %format long; eps=sqrt(10^(0.1*ap)-1); k=1/oms; k1=1/sqrt((10^(0.1*as)-1)/(10^(0.1*ap)-1)); pom=acosh(1/k1)/acosh(oms); if (pom-floor(pom)>0) n=floor(pom+1); else n=floor(pom); end k1new=1/cosh(n*acosh(1/k)); asnew=10*log10((1+(eps^2))/(k1new^2)); knew=1/cosh((acosh(1/k1))/n); omsnew=1/knew; if (opt==0) k=knew; else k1=k1new; end if (ceil(n/2)==n/2) m=floor(n/2); else m=floor((n-1)/2); end pom=sqrt(1+((eps^2)/(k1^2))); a=0.5*((pom+eps/k1)^(1/n)-(pom-eps/k1)^(1/n)); b=0.5*((pom+eps/k1)^(1/n)+(pom-eps/k1)^(1/n)); for f=1:m; pom=1/(k*cos(((2*f-1)*pi)/(2*n))); z(f)=0+pom*i; if (ceil(n/2)~=n/2) z(n-f)=0-pom*i; else z(n-f+1)=0-pom*i; end pom=(a^2)*(sin(((2*f-1)*pi)/(2*n)))^2+(b^2)*(cos(((2*f-1)*pi)/(2*n)))^2; alfa=-1*(a*sin(((2*f-1)*pi)/(2*n)))/(k*pom); beta=(b*cos(((2*f-1)*pi)/(2*n)))/(k*pom); p(f)=alfa-beta*i; p(n-f+1)=alfa+beta*i; end; if (ceil(n/2)~=n/2) p(m+1)=-1/(a*k); %z(m+1)=0; gain=(n*k1)/(eps*k); else gain=1/sqrt(1+(eps^2)/(k1^2)); end;