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

  1. function [a,b,c,d,f,lam]=th2poly(th)
  2. %TH2POLY computes the polynomials associated with a given model
  3. %
  4. %    [A,B,C,D,F,LAM]=th2poly(TH)
  5. %
  6. %    TH is the model with format described by HELP THETA.
  7. %
  8. %    A,B,C,D, and F are returned as the corresponding polynomials
  9. %     in the general input-output model. A, C and D are then row
  10. %    vectors, while B and F have as many rows as there are inputs.
  11. %    LAM is the variance of the noise source.
  12.  
  13. %    L. Ljung 10-1-86
  14. %    Copyright (c) 1986-90 by the MathWorks, Inc.
  15. %    All Rights Reserved.
  16.  
  17.  
  18. if isthss(th),error('TH2POLY does not work for state-space models and Multivariable ARX-models. Use TH2TF or TH2ARX instead!'),end
  19. T=gett(th);
  20. nu=th(1,3);
  21. na=th(1,4);,if nu>0,nb=th(1,5:4+nu);,end,nc=th(1,5+nu);,nd=th(1,6+nu);, if nu>0,nf=th(1,7+nu:6+2*nu);,nk=th(1,7+2*nu:6+3*nu);,end
  22. Nacum=na;,Nbcum=Nacum+sum(nb);,Nccum=Nbcum+nc;,Ndcum=Nccum+nd;
  23. Nfcum=Ndcum+sum(nf);
  24. a=[1 th(3,1:Nacum)];
  25. c=[1 th(3,Nbcum+1:Nccum)];
  26. d=[1 th(3,Nccum+1:Ndcum)];
  27. if nu==0, b=0;,f=1;,end
  28. b=zeros(nu,max(nb+nk));nf1=max(nf)+1;f=zeros(nu,nf1);
  29. s=1;,s1=1;
  30. for k=1:nu
  31.       if nb(k)>0,
  32.       b(k,nk(k)+1:nk(k)+nb(k))=th(3,na+s:na+s+nb(k)-1);
  33.       end
  34.       if T>0,if nf(k)>0,
  35.       f(k,1:nf(k)+1)=[1 th(3,Ndcum+s1:Ndcum+nf(k)+s1-1)];
  36.       else f(k,1)=1;end
  37.       else, if nf(k)>0
  38.       f(k,nf1-nf(k):nf1)=[1 th(3,Ndcum+s1:Ndcum+nf(k)+s1-1)];
  39.       else f(k,nf1)=1;end
  40.       end
  41.       s=s+nb(k);,s1=s1+nf(k);
  42. end
  43.