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

  1. function eta=unfixpar(etaold,mat1,arg1)
  2. %UNFIXPAR    Unfixes parameters in state-space ans ARX model structures
  3. %
  4. %    TH = unfixpar(TH_OLD,MATRIX,ELEMENTS)
  5. %
  6. %    TH : The new theta-matrix
  7. %    TH_OLD: The old theta-matrix
  8. %    MATRIX: What matrix to manipulate 
  9. %        (one of 'A','B','C','D','K' or 'X0')
  10. %    ELEMENTS: Which elements to manipulate; an n by 2 matrix, where
  11. %        each row contains the row- and column numbers
  12. %        of the elements in question.
  13. %
  14. %    Example: th1 = unfixpar(th,'A',[3,1;2,2;1,3]);
  15. %
  16. %       If MATRIX is given the value 'A1', 'A2', etc or 'B0', 'B1' etc
  17. %    the manipulations will be obtained in the corresponding matrix
  18. %    in an ARX-structure, provided TH_OLD is defined as such.
  19. %
  20. %    Note: UNFIXPAR works only on standard model structures
  21. %    originally defined by MS2TH, ARX2TH or ARX; if TH_OLD is based on a
  22. %    user-defined structure (by MF2TH), you must unfix it yourself
  23.  
  24.  
  25. %    L. Ljung 10-2-90
  26. %    Copyright (c) 1990 by the MathWorks, Inc.
  27. %    All Rights Reserved.
  28.  
  29. if nargin<3, arg1=[];end
  30. [nr,nc]=size(etaold);
  31. if ~isthss(etaold) ,[a,b,c,d,f,lam]=th2poly(etaold);[nu,nf]=size(f);
  32. if max([nf length(c) length(d)])==1, etaold=arx2th(a,b,1,1,lam,etaold(1,2));
  33. else
  34. error('This routine is meaningful only for standard state-space structures (originally created by ms2th) and arx structures')
  35. end ,end
  36.  
  37. if ~any(etaold(2,8)==[1 2 3]), 
  38. error('This routine is meaningful only for standard state-space structures (originally created by ms2th) and arx structures')
  39. end 
  40.  
  41.  
  42. [nr,nc]=size(etaold);
  43. nd=etaold(1,5);
  44. ms=getargth(etaold);[par,P,lambda]=th2par(etaold);
  45. [rms,cms]=size(ms);
  46. if etaold(2,8)==3,arx=1;else arx=0;end
  47. if etaold(2,8)==1,cd='c';else cd='d';end
  48. T=etaold(1,2);
  49. if T>0 & etaold(2,8)==1, 
  50. error('This structure is marked as discrete-time, while the underlying parametrization is continuous-time. Do thd2thc first!'),end
  51.  
  52. if mat1(1)~='x' & mat1(1)~='X'
  53.   if length(mat1)>1 
  54.      if ~arx
  55.     error('This option can be used only for ARX-models')
  56.      end
  57.      etapar=etaold(3,1:nd);
  58.      arg=getargth(etaold);
  59.      [rarg,carg]=size(arg);
  60.      as1=arg(:,1:rarg);
  61.      nr=find(sum(as1')==0);
  62.      [as,bs,cs,ds]=ssmodx9(etapar,-1,arg);%FIXA
  63.      [ny,nz]=size(cs);[nx,nz]=size(as);[nz,nu]=size(bs);
  64.      na=(nr(1)-1)/ny;
  65.      if nu>0,nb=(nx-na*ny)/nu;else nb=0;end    
  66.      
  67.      mnr=eval(mat1(2:length(mat1)));
  68.      if mat1(1)=='a' | mat1(1)=='A'
  69.         if mnr>na, error('Matrix number exceeds model order!'),end
  70.      mat1='a'; arg1(:,2)=arg1(:,2)+(mnr-1)*ny;
  71.      end
  72.      if mat1(1)=='b' | mat1(1)=='B'    
  73.         if mnr>nb, error('Matrix number exceeds model order!'),end
  74.         if mnr==0, mat1='b'; 
  75.         else mat1='a';arg1(:,2)=arg1(:,2)+na*ny+(mnr-1)*nu;
  76.         end
  77.     if na==0,if mnr==0,mat1='d';else mat1='c';
  78.     arg1(:,2)=arg1(:,2)+(mnr-1)*nu;end,end
  79.      end
  80.    end
  81. end 
  82.  
  83. [ms,par]=unfixxx(ms,par,mat1,arg1);
  84. [rms,cms]=size(ms);
  85. if arx, ms(1,cms)=-abs(ms(1,cms));end
  86. eta=ms2th(ms,cd,par,lambda,abs(T));
  87. eta(2,7)=26;
  88. if arx, eta(2,8)=3;eta(2,7)=36;end
  89.  
  90.