home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 9.ddi / IDENT.DI$ / GETZP.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.6 KB  |  51 lines

  1. function [z,p] = getzp(zepo,ku,ky)
  2. %GETZP    Extracts the zeros and the poles from the ZEPO-format created by TH2ZP
  3. %
  4. %    [Z,P] = getzp(ZEPO,KU,KY)
  5. %    
  6. %    Z : The zeros
  7. %    P : The poles
  8. %    ZEPO: The matrix of zeros and poles, resulting from th2zp
  9. %    KU : The input number (default 1). Noise source #ju is represented as
  10. %         input number -ju.
  11. %    
  12. %    KY : The output number (default 1).
  13. %
  14. %    If several entries in ZEPO correspond to the same input-output
  15. %    relation, then Z and P will contain one column for each model.
  16. %    Z and P will be stripped from spurious 'inf':s and zeros as far
  17. %    as possible.
  18.  
  19. %    L. Ljung 20-8-90
  20. %    Copyright (c) 1990 by the MathWorks, Inc.
  21. %    All Rights Reserved.
  22.  
  23. if nargin<3, ky=[];end
  24. if nargin<2, ku=[];end
  25. if isempty(ky), ky=1;end
  26. if isempty(ku), ku=1;end
  27. if ku==0,ku=-1;end
  28. if ku<0, ku=500+abs(ku);end
  29. zind = find(abs(zepo(1,:))==(ky-1)*1000+ku);
  30. pind = find(abs(zepo(1,:))==(ky-1)*1000+ku+20);
  31. if isempty(zind),disp('No zeros corresponding to this input/output pair found'),else
  32. zer = zepo(:,zind); [zr,zc]=size(zer); disc=zer(1,1)>0;
  33. zer=zer(2:zr,:);
  34. z=[];
  35. for kc=1:zc
  36. z1 = zer(find(zer(:,kc)~=inf),kc);
  37. if disc, z1 = z1(find(z1~=0)); end
  38. l1=length(z1);[zzr,zzc]=size(z);mr=max(l1,zzr);
  39. z = [[z;ones(mr-zzr,zzc)+inf],[z1;ones(mr-l1,1)+inf]];
  40. end,end
  41. if isempty(pind),disp('No poles corresponding to this input/output pair found'),else
  42. pol = zepo(:,pind); [zr,zc]=size(pol); disc=pol(1,1)>0;
  43. pol=pol(2:zr,:);
  44. p=[];
  45. for kc=1:zc
  46. z1 = pol(find(pol(:,kc)~=inf),kc);
  47. if disc, z1 = z1(find(z1~=0)); end
  48. l1=length(z1);[zzr,zzc]=size(p);mr=max(l1,zzr);
  49. p = [[p;ones(mr-zzr,zzc)+inf],[z1;ones(mr-l1,1)+inf]];
  50. end,end
  51.