Code covered by the BSD License

### Pierre Muret (view profile)

calculate the inductances and capacitances of a non-dissipative analog ladder filter

y11pb(G,H,lim)
```function [numY11,denY11,C] = y11pb(G,H,lim)

%	 [numY11,denY11,C] = y11pb(G,H,lim)
%	 Cauer admittance synthesis from the polynomes G and H, respectively
%    the denominator and the numerator of the reflection coefficients
%	 in the s-parameter matrix of a non-dissipative passive analog filter.
%	 Output gives the vectors containing the polynome coefficients
%	 of the numerator numY11 and denominator denY11 of Y11,
%	 and a cell array C which is the result of a continuous fraction expansion:
%	 the first column C{1:k,1} contains the value
%	 of the passive elements arranged as a ladder;
%	 C{1,1} being the first capacitance in parallel(may be zero),
%	 followed by an inductance in series  C{2,1} ,
%	 followed by a capacitance C{3,1} in parallel, etc.
%	 Alternatively, a Foster synthesis may be obtained by applying the function
%	 'residue' to the ratio numY11/denY11 or to any partial residue saved in C.
%	 lim is a tolerance factor which is used for cleaning out the round up errors
%	 which elsewhere would introduce non zero coefficients without
%	 any physical meaning. The default value is 10*eps.
%	 P. Muret  29 nov 2002

if nargin == 3, ups=abs(G(end)*lim);
else ups=10*abs(G(end)*eps);
end
if nargin ~= 3 & nargin ~= 2
error('the function needs at least 2 arguments.');
end

if prod(size(G)) ~= length(G) | prod(size(H)) ~= length(H)
error('the arguments must be vectors.');
end

ng=length(G);
nh=length(H);
nd=abs(ng-nh);
if nd ~= 0, Z=zeros(1,nd); end
if ng > nh, H=[Z H]; end
if ng < nh, G=[Z G]; end

N = G - hurwitz(G) - (H - hurwitz(H));
D = G + hurwitz(G) + (H + hurwitz(H));
num=N;
den=D;

k=1;
while abs(N(k)) < ups
num(1)=[];
k=k+1;
end

k=1;
while abs(D(k)) < ups
den(1)=[];
k=k+1;
end

numY11=num;
denY11=den;
degnum=length(num)-1;
degden=length(den)-1;
dg=max(degnum,degden);

%	Cauer synthesis

if abs(degnum - degden) ~= 1
error('this is not a non-dissipative LC-element filter');
end

C=cell(dg+1,3);
if degnum > degden
[Q1,R1]=deconv(num,den);
R1(1:2)=[];
else
Q1=0;
R1=num;
end
C{1,1}=Q1;
C{1,2}=R1;
C{1,3}=den;
B=den;
if abs(R1(1)) < ups
error('this is not a non-dissipative LC-element filter');
end

k=2;
while k <= dg
[Q,R]=deconv(B,R1);
R(1:2)=[];
if prod(size(R))~=0
if abs(R(1)) < ups
error('this is not a non-dissipative LC-element filter');
end
end
C{k,1}=Q;
C{k,2}=R;
C{k,3}=R1;
B=R1;
R1=R;
k=k+1;
end

if degnum < degden
[Qn,Rn]=deconv(B,R1);
C{k,1}=Qn;
C{k,2}=Rn;
end
```