Documentation of fixpar


Global Index (short | long) | Local contents | Local Index (short | long)


Function Synopsis

eta=fixpar(etaold,mat1,arg1,fixpar)

Help text

FIXPAR   Fixes parameters in state-space and ARX model structures.
   TH = FIXPAR(TH_OLD,MATRIX,ELEMENTS,PARAMETERVALUES)

   TH : The new theta-matrix
   TH_OLD: The old theta-matrix
   MATRIX: What matrix to manipulate (one of 'A','B','C','D','K' or 'X0')
   ELEMENTS: Which elements to manipulate; an n by 2 matrix, where   each
   row contains the row- and column numbers of the elements in question.
   If this argument is omitted, all elements in the matrix will be fixed.
   PARAMETERVALUES: The values of the new, fixed parameters;a vector with
   n entries. If this argument is omitted, the parameters will be fixed to
   the values of the current estimates in TH_OLD.
   If MATRIX is given the value 'A1', 'A2', etc or 'B0', 'B1' etc
   the manipulations will be obtained in the corresponding matrix
   in an ARX-structure, provided TH_OLD is defined as such.

   Example: th1 = FIXPAR(th,'A',[3,1;2,2;1,3])

   Note: FIXPAR works only on standard model structures originally
   defined by MS2TH, ARX2TH or ARX; if TH_OLD is based on a user-
   defined structure, you could obtain the same result with THINIT and by
   using the 3rd argument in PEM.
   See also ARX, ARX2TH, MS2TH, PEM, UNFIXPAR.

Cross-Reference Information

This function calls This function is called by

Listing of function fixpar

function eta=fixpar(etaold,mat1,arg1,fixpar)

%   L. Ljung 10-4-90,3-13-93
%   Copyright (c) 1986-98 by The MathWorks, Inc.
%   $Revision: 2.4 $  $Date: 1997/12/02 03:44:10 $

if nargin < 2
   disp('Usage: THF = FIXPAR(TH,MATRIX)')
   disp('       THF = FIXPAR(TH,MATRIX,ELEMENTS,PARAMETER_VALUES)')
   disp('       MATRIX is one of ''A'', ''B'', ''C'', ''D'', ''K'', ''X0''.')
   disp('       or ''B0'', ''A1'', ''B1'', ''A2'', ''B2'', etc.')
   return
end

if nargin<4,fixpar='d'; deff=1;else deff=0;end
if nargin<3,arg1=[];end

if nargin==4,[npr,npc]=size(arg1);if ~isempty(arg1)&length(fixpar)~=npr,
   error(['The length of the new parameter vector does not match the',...
   ' number of matrix entries marked']),end,end
if ~isthss(etaold)
    [a,b,c,d,f,lam]=th2poly(etaold);[nu,nf]=size(f);
    if max([nf length(c) length(d)])==1,
       etaold=arx2th(a,b(:)',1,nu,lam,etaold(1,2));
    else
       error(['This routine is meaningful only for standard state-space',...
           ' structures (originally created by ms2th) and arx structures.'])
    end
end
if ~any(etaold(2,8)==[1 2 3]),
    error(['This routine is meaningful only for standard state-space',...
       ' structures (originally created by ms2th) and arx structures.'])
end
[nr,nc]=size(etaold);
nd=etaold(1,5);
ms=getargth(etaold);[par,P,lambda]=th2par(etaold);
[rms,cms]=size(ms);

if etaold(2,8)==3,arx=1;else arx=0;end
if etaold(2,8)==1,cd='c';else cd='d';end
T=etaold(1,2);
if T>0 & etaold(2,8)==1,
    error(['This structure is marked as discrete-time, while the underl',...
           'ying parametrization is continuous-time. Do thd2thc first.'])
end
if mat1(1)~='x' & mat1(1)~='X'
  if length(mat1)>1
     if ~arx
   error('This option can be used only for ARX-models')
     end
     etapar=etaold(3,1:nd);
     arg=getargth(etaold);
     [rarg,carg]=size(arg);
     as1=arg(:,1:rarg);
     sumas=sum4vms(as1');
     nr=find(sumas==0&~isnan(sumas));
     if isempty(nr), nr=length(as1)+1;end
     [as,bs,cs,ds]=ssmodx9(etapar,-1,arg);
     [ny,nz]=size(cs);[nx,nz]=size(as);[nz,nu]=size(bs);
     na=(nr(1)-1)/ny;
     if nu>0,nb=(nx-na*ny)/nu;else nb=0;end

     mnr=eval(mat1(2:length(mat1)));
     if mat1(1)=='a' | mat1(1)=='A'
        if mat1(2)=='0',error('A0 cannot be changed'),end
        if mnr>na, error('Matrix number exceeds model order!'),end
     if isempty(arg1)
        for kkll1=1:ny,for kkll2=1:ny,arg1=[arg1;[kkll1,kkll2]];end,end
        [nopar,dum]=size(arg1);
        if length(fixpar)==1,fixpar=fixpar*ones(1,nopar);end
     end
     mat1='a'; arg1(:,2)=arg1(:,2)+(mnr-1)*ny;if ~deff,fixpar=-fixpar;end
     end
     if mat1(1)=='b' | mat1(1)=='B'
     if isempty(arg1)
        for kkll1=1:ny,for kkll2=1:nu,arg1=[arg1;[kkll1,kkll2]];end,end
        [nopar,dum]=size(arg1);
        if length(fixpar)==1,fixpar=fixpar*ones(1,nopar);end
     end
        if mnr>nb, error('Matrix number exceeds model order!'),end
        if mnr==0, mat1='b';
        else mat1='a';arg1(:,2)=arg1(:,2)+na*ny+(mnr-1)*nu;
        end
   if na==0,if mnr==0,mat1='d';else mat1='c';
   arg1(:,2)=arg1(:,2)+(mnr-1)*nu;end,end
     end
   end
end
[ms,par]=fixxx(ms,par,mat1,arg1,fixpar);
[rms,cms]=size(ms);if arx,ms(1,cms)=-ms(1,cms);end

eta=ms2th(ms,cd,par,lambda,abs(T));
eta(2,7)=25;
if arx, eta(2,8)=3;eta(2,7)=35;end