home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------
- //
- // lqry
- //
- // Syntax: G=lqry(A,B,Q,R,CT)
- //
- // This routine computes the Linear Quadratic Design for Continuous Systems
- // with weighting on the outputs. It calculates the optimal feedback gain
- // matrix K such that the feedbakc law u = -Kx minimizes the following
- // cost function:
- //
- // Inf
- // J = Integral ( y'Qy + u'Ru ) dt
- // 0
- //
- // subject to the constraint
- //
- // .
- // x = Ax + Bu
- // y = Cx + Du
- //
- // Note: Three matrices are returned in a list.
- //
- // G.k = Optimal Feedback Gain matrix
- // G.s = Steady-State Solution to the Algebraic Riccatti Eqn.
- // G.e = Closed Loop eigenvalues
- //
- //
- // Copyright (C), by Jeffrey B. Layton, 1994
- // Version JBL 940919
- //----------------------------------------------------------------------------
-
- rfile lqr
-
- lqry = function(a,b,c,d,q,r)
- {
- local(nargs,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("LQRY: Wrong number of input arguments.");
- }
-
- t=lqr(a,b, c'*q*c, r+d'*q*d, c'*q*d);
-
- return << k=t.k; s=t.s; e=t.e >>
- };
-