discrete-time state-space realization and Kalman gain
[[A,C][,B[,D]][,K,Q,Ry,S][,rcnd]] = sident(meth,job,s,n,l,R[,tol,t,Ai,Ci,printw])
meth integer option to determine the method to use: | |
---|---|
:= 1 : MOESP method with past inputs and outputs; : := 2 : N4SID method; : := 3 : combined method: A and C via MOESP, B and D via N4SID. : |
: :n integer, the order of the system : :l integer, the number of the system outputs : :R the 2*(m+l)*s-by-2*(m+l)*s part of R contains the processed upper
triangular factor R from the QR factorization of the concatenated block-Hankel matrices, and further details needed for computing system matrices.
: :Ai real matrix : :Ci real matrix : :printw (optional) switch for printing the warning messages.
= 1: print warning messages; : := 0: do not print warning messages. :
Default: printw = 0. : :A real matrix : :C real matrix : :B real matrix : :D real matrix : :K real matrix, kalman gain : :Q (optional) the n-by-n positive semidefinite state covariance
matrix used as state weighting matrix when computing the Kalman gain.
:
SIDENT function for computing a discrete-time state-space realization (A,B,C,D) and Kalman gain K using SLICOT routine IB01BD.
[A,C,B,D] = sident(meth,1,s,n,l,R)
[A,C,B,D,K,Q,Ry,S,rcnd] = sident(meth,1,s,n,l,R,tol,t)
[A,C] = sident(meth,2,s,n,l,R)
B = sident(meth,3,s,n,l,R,tol,0,Ai,Ci)
[B,K,Q,Ry,S,rcnd] = sident(meth,3,s,n,l,R,tol,t,Ai,Ci)
[B,D] = sident(meth,4,s,n,l,R,tol,0,Ai,Ci)
[B,D,K,Q,Ry,S,rcnd] = sident(meth,4,s,n,l,R,tol,t,Ai,Ci)
SIDENT computes a state-space realization (A,B,C,D) and the Kalman predictor gain K of a discrete-time system, given the system order and the relevant part of the R factor of the concatenated block-Hankel matrices, using subspace identification techniques (MOESP, N4SID, or their combination).
The model structure is :
x(k+1) = Ax(k) + Bu(k) + Ke(k), k >= 1,
y(k) = Cx(k) + Du(k) + e(k),
where x(k) is the n-dimensional state vector (at time k),
u(k) is the m-dimensional input vector,
y(k) is the l-dimensional output vector,
e(k) is the l-dimensional disturbance vector,
and A, B, C, D, and K are real matrices of appropriate dimensions.
1. The n-by-n system state matrix A, and the p-by-n system output matrix C are computed for job <= 2.
4. The n-by-l Kalman predictor gain matrix K and the covariance matrices Q, Ry, and S are computed for t > 0.
//generate data from a given linear system
A = [ 0.5, 0.1,-0.1, 0.2;
0.1, 0, -0.1,-0.1;
-0.4,-0.6,-0.7,-0.1;
0.8, 0, -0.6,-0.6];
B = [0.8;0.1;1;-1];
C = [1 2 -1 0];
SYS=`syslin`_(0.1,A,B,C);
nsmp=100;
U=`prbs_a`_(nsmp,nsmp/5);
Y=(`flts`_(U,SYS)+0.3*`rand`_(1,nsmp,'normal'));
S = 15;
N = 3;
METH=1;
[R,N1] = `findR`_(S,Y',U',METH);
[A,C,B,D,K] = sident(METH,1,S,N,1,R);
SYS1=`syslin`_(1,A,B,C,D);
SYS1.X0 = `inistate`_(SYS1,Y',U');
Y1=`flts`_(U,SYS1);
`clf`_();`plot2d`_((1:nsmp)',[Y',Y1'])
METH = 2;
[R,N1,SVAL] = `findR`_(S,Y',U',METH);
tol = 0;
t = `size`_(U',1)-2*S+1;
[A,C,B,D,K] = sident(METH,1,S,N,1,R,tol,t)
SYS1=`syslin`_(1,A,B,C,D)
SYS1.X0 = `inistate`_(SYS1,Y',U');
Y1=`flts`_(U,SYS1);
`clf`_();`plot2d`_((1:nsmp)',[Y',Y1'])