Global Index (short | long) | Local contents | Local Index (short | long)
[A,B,C,D,K,X0]=ssmodx8(th,T,mod)
SSMODX8 The standard state-space model [A,B,C,D,K,X0] = ssmodx8(PARVAL,T,MS) This routine is used as the standard model-defining routine inside the THETA-structure for state space models if no user- defined structure is specified. The use of SSMODx8 should be transparent to the user. This is a variant of ssmodx9, that samples the systems under the assumption that the input is piecewise linear between the samples ('first order hold') A,B etc: The discrete time state space matrices corresponding to the parameter values PARVAL for a linear model structure defined by MS (obtained from MODSTRUC or CANFORM)
This function calls | This function is called by |
---|---|
function [A,B,C,D,K,X0]=ssmodx8(th,T,mod) % L. Ljung 10-2-90,1-9-93 % Copyright (c) 1986-98 by The MathWorks, Inc. % $Revision: 2.3 $ $Date: 1997/12/02 03:44:25 $ [nx,nn]=size(mod);nyy=mod(1,nn);nx=mod(2,nn); ny=abs(nyy);nu=(nn-nx-2*ny-2)/2; s=1; if nyy<0,arx=1;else arx=0;end na=0; if arx, as1=mod(1:nx,1:nx); sumas=sum4vms(as1'); nr=find(sumas==0&~isnan(sumas)); if isempty(nr),na=nx/ny;else na=(nr(1)-1)/ny;end end A=mod(1:nx,1:nx); for kr=1:nx for kc=1:nx if isnan(A(kr,kc)), A(kr,kc)=th(s);s=s+1;end end end B=mod(1:nx,nx+1:nx+nu); for kr=1:nx for kc=1:nu if isnan(B(kr,kc)),B(kr,kc)=th(s);s=s+1;end end end if na==0 C=mod(1:nx,nx+nu+1:nx+nu+ny)'; for kr=1:ny for kc=1:nx if isnan(C(kr,kc)),C(kr,kc)=th(s);s=s+1;end end end D=mod(1:ny,nx+nu+ny+1:nx+2*nu+ny); for kr=1:ny for kc=1:nu if isnan(D(kr,kc)),D(kr,kc)=th(s);s=s+1;end end end else C=A(1:ny,1:nx); D=B(1:ny,:); end K=mod(1:nx,nx+2*nu+ny+1:nx+2*nu+2*ny); for kr=1:nx for kc=1:ny if isnan(K(kr,kc)),K(kr,kc)=th(s);s=s+1;end end end X0=mod(1:nx,nx+2*nu+2*ny+1); for kr=1:nx if isnan(X0(kr)),X0(kr)=th(s);s=s+1;end end if T>0 % We shall in this case sample the model with sampling interval T % using first order hold nuy = nu+ny; s = expm([[A [B K] zeros(nx,nuy)]*T;[zeros(nuy,nx+nuy),T*eye(nuy)];... zeros(nu+ny,nx+2*nuy)]); A = s(1:nx,1:nx); gtil = s(1:nx,nx+nuy+1:nx+2*nuy); BK = s(1:nx,nx+1:nx+nuy)+(A-eye(nx))*gtil/T; B = BK(:,1:nu); K = BK(:,nu+1:nuy); D = D+C*gtil(:,1:nu)/T; end