home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------
- //
- // lqe
- //
- // Syntax: G=lqe(A,D,M,Q,R,CT)
- //
- // This routine computes the Linear Quadratic Estimator Design for continuous
- // systems. The system is given by the following differential equations:
- // .
- // x = Ax + Bu + Dw
- // z = Mx + Gu + v
- //
- // where z is the vector of sensor measurements, w is the vector if process
- // noise, and v is the vector of sensor noise. The system has the following
- // process noise and measurement noise covariances:
- //
- // E(w) = E(v) = 0
- // E(ww') = Q
- // E(vv') = R
- // E(wv') = 0
- //
- // where E is the expectation operator. The gain matrix L is designed such
- // that the stationary Kalman filter:
- // .
- // x = Ax + Bu + L(z - Mx - Gu)
- //
- // produces an LQG optimal estimate of x. If CT exists then the process and
- // sensor noise are correlated: E(wv') = CT.
- //
- // This routine takes advantage of the dual nature of the optimal estimator,
- // by using the lqr routine to compute the optimal estimator.
- //
- // Note: Three matrices are returned in a list.
- //
- // G.l = Optimal Estimator Gain matrix
- // G.p = Riccatti Eqn. Solution, which is the estimate error covariance
- // G.e = Closed Loop eigenvalues of the estimator eig(A-L*M)
- //
- // Ref: (1) Skelton, R. "Dynamic Systems Control Linear System Analysis and
- // Synthesis," John Wiley and Sons, 1988.
- //
- // Copyright (C), by Jeffrey B. Layton, 1994
- // Version JBL 940918
- //----------------------------------------------------------------------------
-
- rfile lqr
-
- lqe = function(a,d,m,q,r,ct)
- {
- local(nargs,d)
-
- // Count number of input arguments
- nargs=0;
- if (exist(a)) {nargs=nargs+1;}
- if (exist(d)) {nargs=nargs+1;}
- if (exist(m)) {nargs=nargs+1;}
- if (exist(q)) {nargs=nargs+1;}
- if (exist(r)) {nargs=nargs+1;}
- if (exist(ct)) {nargs=nargs+1;}
-
- if ( nargs < 5) {
- error("LQE: Wrong number of input arguments.");
- }
-
- // Don't do any error checking, let lqr take care of that.
- if ( exist(ct)) {
- d=lqr(a',m',d*q*d',r,d*ct);
- else
- d=lqr(a',m',d*q*d',r);
- }
-
- return << l=d.k'; p=d.p'; e=d.e >>
- };
-