home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 10.ddi / CONTROL.DI$ / ZP2TF.M < prev   
Encoding:
Text File  |  1993-03-11  |  1.0 KB  |  40 lines

  1. function [num,den] = zp2tf(z,p,k)
  2. %ZP2TF    Zero-pole to transfer function conversion.
  3. %    [NUM,DEN] = ZP2TF(Z,P,K)  forms the transfer function:
  4. %
  5. %                    NUM(s)
  6. %            H(s) = -------- 
  7. %                    DEN(s)
  8. %
  9. %    given a set of zero locations in vector Z, a set of pole locations
  10. %    in vector P, and a gain in scalar K.  Vectors NUM and DEN are 
  11. %    returned with numerator and denominator coefficients in descending
  12. %    powers of s.  
  13. %
  14. %    See also: TF2ZP.
  15.  
  16. %     J.N. Little 7-17-85
  17. %    Revised 6-27-88
  18. %    Copyright (c) 1986-93, by the MathWorks, Inc.
  19.  
  20. %    Note: the following will not work if p or z have elements not
  21. %    in complex pairs.
  22.  
  23. den = real(poly(p(:)));
  24. [md,nd] = size(den);
  25. k = k(:);
  26. [mk,nk] = size(k);
  27. if isempty(z), num = [zeros(mk,nd-1),k]; return; end
  28. [m,n] = size(z);
  29. if mk ~= n
  30.     if m == 1
  31.         error('Z and P must be column vectors.');
  32.     end
  33.     error('K must have as many elements as Z has columns.');
  34. end
  35. for j=1:n
  36.     zj = z(:,j);
  37.     pj = real(poly(zj)*k(j));
  38.     num(j,:) = [zeros(1,nd-length(pj)) pj];
  39. end
  40.