function [r,p]=zp2rp(z,p,g); %ZP2RP converts the pole-zero form to residue form. % [R,P]=ZPK2RPK(Z,P,G) converts the pole-zero from given by % the poles P, zeros Z, and series constant gain G to the partial % fraction form with poles P and residues R. % % The partial fraction expansion is computed in the pole-zero form, % therefore it is numerically more robust than converting it first % to direct form and then to parallel form. % % The function requires that the number of zeros is smaller than the % number of poles length(Z)=N, error('The number of zeros must be smaller than the number of poles.'); end; r=zeros(size(p)); for l=1:N, r(l)=g*p(l).^(N-M-1); for i=1:M, r(l)=r(l)*(p(l)-z(i)); end; for i=1:N, if l ~= i, r(l)=r(l)/(p(l)-p(i)); end; end; end;