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

  1. function [A,B,dA,dB]=th2arx(eta)
  2. %TH2ARX converts a THETA-format model to an ARX-model
  3. %
  4. %    [A,B]=th2arx(TH)
  5. %
  6. %    TH: The model structure defined in the THETA-format (See help theta)
  7. %    A, B : Matrices defining the ARX-structure:
  8. %
  9. %           y(t) + A1 y(t-1) + .. + An y(t-n) = 
  10. %           = B0 u(t) + ..+ B1 u(t-1) + .. Bm u(t-m)
  11. %
  12. %           A = [I A1 A2 .. An],  B=[B0 B1 .. Bm]
  13. %
  14. %
  15. %    With [A,B,dA,dB] = th2arx(TH), also the standard deviations
  16. %    of A and B, i.e. dA and dB are computed.
  17. %
  18. %    See also ARX2TH, and ARX
  19.  
  20. %    L. Ljung 10-2-90
  21. %    Copyright (c) 1990 by the MathWorks, Inc.
  22. %    All Rights Reserved.
  23.  
  24. [Ncap,nd]=getncap(eta);
  25. if ~isthss(eta), [A,B]=th2poly(eta);
  26. if nargout>2,[par,P]=th2par(eta);eta1=eta;eta1(3,1:nd)=par+sqrt(diag(P))';
  27. [A1,B1]=th2poly(eta1);dA=abs(A-A1);dB=abs(B-B1);end,return,end
  28.  
  29. tnr=eta(2,8); if tnr~=3,error('This is not an ARX-model!'),end
  30. etapar=eta(3,1:nd);
  31. arg=getargth(eta);
  32. [rarg,carg]=size(arg);
  33. as1=arg(:,1:rarg);
  34. nr=find(sum(as1')==0);end
  35. [as,bs,cs,ds]=ssmodx9(etapar,-1,arg);%FIXA
  36. [ny,nz]=size(cs);[nx,nz]=size(as);[nz,nu]=size(bs);
  37. if isempty(nr),na=nx/ny;else na=(nr(1)-1)/ny;end
  38. if nu>0,nb=(nx-na*ny)/nu;else nb=0;end
  39. A=[eye(ny) -cs(:,1:na*ny)];
  40. if nu>0,B=[ds cs(:,na*ny+1:nx)];else B=[];end
  41. if na==0 & ~any(isnan(arg(:,nx+nu+1:nx+nu+ny))), B=ds;end
  42.  
  43. if nargout>2
  44. p=diag(eta(4:3+nd,1:nd));p=sqrt(p')+eps;
  45. etap1=etapar+p;
  46. [das,dbs,dcs,dds]=ssmodx9(etap1,-1,arg);
  47. dA=abs([eye(ny) -dcs(:,1:na*ny)]-A);
  48. if nu>0,dB=abs([dbs(1:ny,:) dcs(:,na*ny+1:nx)]-B);else dB=[];end
  49. end
  50.  
  51.