home *** CD-ROM | disk | FTP | other *** search
- //-----------------------------------------------------------------------------
- //
- // dlqry
- //
- // Syntax: A=dlqry(a,b,c,d,q,r)
- //
- // This routine computes the Linear Quadratic Design for Discrete Systems
- // with weighting on the outputs. It calculates the optimal feedback gain
- // matrix K such that the feedbakc law u(n) = -Kx(n) minimizes the following
- // cost function:
- //
- // J = Sum ( y'Qy + u'Ru ) dt
- //
- // subject to the constraint
- //
- // x[n+1] = Ax[n] + Bu[n]
- // y[n] = Cx[n] + Du[n]
- //
- // Note: Three matrices are returned in a list.
- //
- // A.k = Optimal Feedback Gain matrix
- // A.s = Steady-State Solution to the Algebraic Riccatti Eqn.
- // A.e = Closed Loop eigenvalues
- //
- // Copyright (C), by Jeffrey B. Layton, 1994
- // Version JBL 940918
- //-----------------------------------------------------------------------------
-
- rfile dlqr
-
- dlqry = function(a,b,c,d,q,r)
- {
- local(t)
-
- // Count number of input arguments
- nargs=0;
- if (exist(a)) {nargs=nargs+1;}
- if (exist(b)) {nargs=nargs+1;}
- if (exist(c)) {nargs=nargs+1;}
- if (exist(d)) {nargs=nargs+1;}
- if (exist(q)) {nargs=nargs+1;}
- if (exist(r)) {nargs=nargs+1;}
-
- if (nargs < 6) {
- error("DLQRY: Wrong number of input arguments.");
- }
-
- t=dlqr(a,b, c'*q*c, r+d'*q*d, c'*q*d);
-
- return << k=t.k; s=t.s; e=t.e >>
- };
-