From: <par...@us...> - 2012-06-21 07:17:01
|
Revision: 10649 http://octave.svn.sourceforge.net/octave/?rev=10649&view=rev Author: paramaniac Date: 2012-06-21 07:16:50 +0000 (Thu, 21 Jun 2012) Log Message: ----------- control: move completed functions into place Modified Paths: -------------- trunk/octave-forge/main/control/INDEX trunk/octave-forge/main/control/NEWS Added Paths: ----------- trunk/octave-forge/main/control/inst/dlqe.m trunk/octave-forge/main/control/inst/lqe.m Removed Paths: ------------- trunk/octave-forge/main/control/devel/dlqe.m trunk/octave-forge/main/control/devel/lqe.m Modified: trunk/octave-forge/main/control/INDEX =================================================================== --- trunk/octave-forge/main/control/INDEX 2012-06-21 07:08:29 UTC (rev 10648) +++ trunk/octave-forge/main/control/INDEX 2012-06-21 07:16:50 UTC (rev 10649) @@ -78,9 +78,11 @@ place rlocus Linear-Quadratic Control + dlqe dlqr estim kalman + lqe lqr Robust Control augw Modified: trunk/octave-forge/main/control/NEWS =================================================================== --- trunk/octave-forge/main/control/NEWS 2012-06-21 07:08:29 UTC (rev 10648) +++ trunk/octave-forge/main/control/NEWS 2012-06-21 07:16:50 UTC (rev 10649) @@ -7,8 +7,12 @@ ** Fixed a silly mistake in MIMO transfer function to state-space conversion. The bug has been introduced with control-2.3.51. (Thanks to Jim Rawlings for providing the test case) - +** dlqe, lqe + Added new functions for linear quadratic estimators. + (Thanks to Megan Zagrobelny) + + =============================================================================== control-2.3.51 Release Date: 2012-06-03 Release Manager: Lukas Reichlin =============================================================================== Deleted: trunk/octave-forge/main/control/devel/dlqe.m =================================================================== --- trunk/octave-forge/main/control/devel/dlqe.m 2012-06-21 07:08:29 UTC (rev 10648) +++ trunk/octave-forge/main/control/devel/dlqe.m 2012-06-21 07:16:50 UTC (rev 10649) @@ -1,105 +0,0 @@ -## Copyright (C) 2012 Lukas F. Reichlin -## Copyright (C) 2012 Megan Zagrobelny -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}, @var{s}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}, @var{s}) -## Kalman filter for discrete-time systems. -## -## @example -## @group -## x[k] = Ax[k] + Bu[k] + Gw[k] (State equation) -## y[k] = Cx[k] + Du[k] + v[k] (Measurement Equation) -## E(w) = 0, E(v) = 0, cov(w) = Q, cov(v) = R, cov(w,v) = S -## @end group -## @end example -## -## @strong{Inputs} -## @table @var -## @item sys -## Continuous or discrete-time LTI model (p-by-m, n states). -## @item a -## State transition matrix of discrete-time system (n-by-n). -## @item g -## Process noise matrix of discrete-time system (n-by-g). -## @item c -## Measurement matrix of discrete-time system (p-by-n). -## @item q -## Process noise covariance matrix (g-by-g). -## @item r -## Measurement noise covariance matrix (p-by-p). -## @item s -## Optional cross term covariance matrix (g-by-p), s = cov(w,v) If @var{s} is not specified, a zero matrix is assumed. -## @end table -## -## @strong{Outputs} -## @table @var -## @item l -## Kalman filter gain matrix (n-by-p). -## @item p -## Unique stabilizing solution of the discrete-time Riccati equation (n-by-n). -## @item z -## Error covariance (n-by-n), cov(x(k|k)-x) -## @item e -## Closed-loop poles (n-by-1). -## @end table -## -## @strong{Equations} -## @example -## @group -## x[k|k] = x[k|k-1] + L(y[k] - Cx[k|k-1] -Du[k]) -## -## x[k+1|k] = Ax[k|k] + Bu[k] for S=0 -## -## x[k+1|k] = Ax[k|k] + Bu[k] + G*S*(C*P*C' + R)^-1*(y[k] - C*x[k|k-1]) for non-zero S -## -## -## E = eig(A - A*L*C) for S=0 -## -## E = eig(A - A*L*C - G*S*(C*P*C' + Rv)^-1*C) for non-zero S -## -## @end group -## @end example -## @seealso{dare, care, dlqr, lqr, lqe} -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: April 2012 -## Version: 0.1 - -function [l, p, z, e] = dlqe (a, g, c, q, r, s = []) - - if (nargin < 5 || nargin > 6) - print_usage (); - endif - - if (isempty (g)) - [~, p, e] = dlqr (a.', c.', q, r, s); # dlqe (a, [], c, q, r, s), g=I - elseif (isempty (s)) - [~, p, e] = dlqr (a.', c.', g*q*g.', r); - else - [~, p, e] = dlqr (a.', c.', g*q*g.', r, g*s); - endif - - l = p*c.' / (c*p*c.' + r); - - z = p - l*c*p; - -endfunction Deleted: trunk/octave-forge/main/control/devel/lqe.m =================================================================== --- trunk/octave-forge/main/control/devel/lqe.m 2012-06-21 07:08:29 UTC (rev 10648) +++ trunk/octave-forge/main/control/devel/lqe.m 2012-06-21 07:16:50 UTC (rev 10649) @@ -1,100 +0,0 @@ -## Copyright (C) 2012 Lukas F. Reichlin -## Copyright (C) 2012 Megan Zagrobelny -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{sys}, @var{q}, @var{r}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{sys}, @var{q}, @var{r}, @var{s}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}, @var{s}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}, @var{s}) -## Kalman filter for continuous-time systems. -## -## @example -## @group -## . -## x = Ax + Bu + Gw (State equation) -## y = Cx + Du + v (Measurement Equation) -## E(w) = 0, E(v) = 0, cov(w) = Q, cov(v) = R, cov(w,v) = S -## @end group -## @end example -## -## @strong{Inputs} -## @table @var -## @item sys -## Continuous or discrete-time LTI model (p-by-m, n states). -## @item a -## State transition matrix of continuous-time system (n-by-n). -## @item g -## Process noise matrix of continuous-time system (n-by-g). -## @item c -## Measurement matrix of continuous-time system (p-by-n). -## @item q -## Process noise covariance matrix (g-by-g). -## @item r -## Measurement noise covariance matrix (p-by-p). -## @item s -## Optional cross term covariance matrix (g-by-p), s = cov(w,v) If @var{s} is not specified, a zero matrix is assumed. -## @end table -## -## @strong{Outputs} -## @table @var -## @item l -## Kalman filter gain matrix (n-by-p). -## @item p -## Unique stabilizing solution of the continuous-time Riccati equation (n-by-n). -## @item e -## Closed-loop poles (n-by-1). -## @end table -## -## @strong{Equations} -## @example -## @group -## . -## x = Ax + Bu + L(y - Cx -Du) -## -## E = eig(A - L*C) -## -## @end group -## @end example -## @seealso{dare, care, dlqr, lqr, dlqe} -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: April 2012 -## Version: 0.1 - -function [l, p, e] = lqe (a, g, c, q = [], r = [], s = []) - - if (nargin < 3 || nargin > 6) - print_usage (); - endif - - if (isa (a, "lti")) - [l, p, e] = lqr (a.', g, c, q); # lqe (sys, q, r, s), g=I, works like lqr (sys.', q, r, s).' - elseif (isempty (g)) - [l, p, e] = lqr (a.', c.', q, r, s); # lqe (a, [], c, q, r, s), g=I, works like lqr (a.', c.', q, r, s).' - elseif (isempty (s)) - [l, p, e] = lqr (a.', c.', g*q*g.', r); - else - [l, p, e] = lqr (a.', c.', g*q*g.', r, g*s); - endif - - l = l.'; - -endfunction Copied: trunk/octave-forge/main/control/inst/dlqe.m (from rev 10648, trunk/octave-forge/main/control/devel/dlqe.m) =================================================================== --- trunk/octave-forge/main/control/inst/dlqe.m (rev 0) +++ trunk/octave-forge/main/control/inst/dlqe.m 2012-06-21 07:16:50 UTC (rev 10649) @@ -0,0 +1,105 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## Copyright (C) 2012 Megan Zagrobelny +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}, @var{s}) +## Kalman filter for discrete-time systems. +## +## @example +## @group +## x[k] = Ax[k] + Bu[k] + Gw[k] (State equation) +## y[k] = Cx[k] + Du[k] + v[k] (Measurement Equation) +## E(w) = 0, E(v) = 0, cov(w) = Q, cov(v) = R, cov(w,v) = S +## @end group +## @end example +## +## @strong{Inputs} +## @table @var +## @item sys +## Continuous or discrete-time LTI model (p-by-m, n states). +## @item a +## State transition matrix of discrete-time system (n-by-n). +## @item g +## Process noise matrix of discrete-time system (n-by-g). +## @item c +## Measurement matrix of discrete-time system (p-by-n). +## @item q +## Process noise covariance matrix (g-by-g). +## @item r +## Measurement noise covariance matrix (p-by-p). +## @item s +## Optional cross term covariance matrix (g-by-p), s = cov(w,v) If @var{s} is not specified, a zero matrix is assumed. +## @end table +## +## @strong{Outputs} +## @table @var +## @item l +## Kalman filter gain matrix (n-by-p). +## @item p +## Unique stabilizing solution of the discrete-time Riccati equation (n-by-n). +## @item z +## Error covariance (n-by-n), cov(x(k|k)-x) +## @item e +## Closed-loop poles (n-by-1). +## @end table +## +## @strong{Equations} +## @example +## @group +## x[k|k] = x[k|k-1] + L(y[k] - Cx[k|k-1] -Du[k]) +## +## x[k+1|k] = Ax[k|k] + Bu[k] for S=0 +## +## x[k+1|k] = Ax[k|k] + Bu[k] + G*S*(C*P*C' + R)^-1*(y[k] - C*x[k|k-1]) for non-zero S +## +## +## E = eig(A - A*L*C) for S=0 +## +## E = eig(A - A*L*C - G*S*(C*P*C' + Rv)^-1*C) for non-zero S +## +## @end group +## @end example +## @seealso{dare, care, dlqr, lqr, lqe} +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: April 2012 +## Version: 0.1 + +function [l, p, z, e] = dlqe (a, g, c, q, r, s = []) + + if (nargin < 5 || nargin > 6) + print_usage (); + endif + + if (isempty (g)) + [~, p, e] = dlqr (a.', c.', q, r, s); # dlqe (a, [], c, q, r, s), g=I + elseif (isempty (s)) + [~, p, e] = dlqr (a.', c.', g*q*g.', r); + else + [~, p, e] = dlqr (a.', c.', g*q*g.', r, g*s); + endif + + l = p*c.' / (c*p*c.' + r); + + z = p - l*c*p; + +endfunction Copied: trunk/octave-forge/main/control/inst/lqe.m (from rev 10648, trunk/octave-forge/main/control/devel/lqe.m) =================================================================== --- trunk/octave-forge/main/control/inst/lqe.m (rev 0) +++ trunk/octave-forge/main/control/inst/lqe.m 2012-06-21 07:16:50 UTC (rev 10649) @@ -0,0 +1,100 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## Copyright (C) 2012 Megan Zagrobelny +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{sys}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{sys}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}, @var{s}) +## Kalman filter for continuous-time systems. +## +## @example +## @group +## . +## x = Ax + Bu + Gw (State equation) +## y = Cx + Du + v (Measurement Equation) +## E(w) = 0, E(v) = 0, cov(w) = Q, cov(v) = R, cov(w,v) = S +## @end group +## @end example +## +## @strong{Inputs} +## @table @var +## @item sys +## Continuous or discrete-time LTI model (p-by-m, n states). +## @item a +## State transition matrix of continuous-time system (n-by-n). +## @item g +## Process noise matrix of continuous-time system (n-by-g). +## @item c +## Measurement matrix of continuous-time system (p-by-n). +## @item q +## Process noise covariance matrix (g-by-g). +## @item r +## Measurement noise covariance matrix (p-by-p). +## @item s +## Optional cross term covariance matrix (g-by-p), s = cov(w,v) If @var{s} is not specified, a zero matrix is assumed. +## @end table +## +## @strong{Outputs} +## @table @var +## @item l +## Kalman filter gain matrix (n-by-p). +## @item p +## Unique stabilizing solution of the continuous-time Riccati equation (n-by-n). +## @item e +## Closed-loop poles (n-by-1). +## @end table +## +## @strong{Equations} +## @example +## @group +## . +## x = Ax + Bu + L(y - Cx -Du) +## +## E = eig(A - L*C) +## +## @end group +## @end example +## @seealso{dare, care, dlqr, lqr, dlqe} +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: April 2012 +## Version: 0.1 + +function [l, p, e] = lqe (a, g, c, q = [], r = [], s = []) + + if (nargin < 3 || nargin > 6) + print_usage (); + endif + + if (isa (a, "lti")) + [l, p, e] = lqr (a.', g, c, q); # lqe (sys, q, r, s), g=I, works like lqr (sys.', q, r, s).' + elseif (isempty (g)) + [l, p, e] = lqr (a.', c.', q, r, s); # lqe (a, [], c, q, r, s), g=I, works like lqr (a.', c.', q, r, s).' + elseif (isempty (s)) + [l, p, e] = lqr (a.', c.', g*q*g.', r); + else + [l, p, e] = lqr (a.', c.', g*q*g.', r, g*s); + endif + + l = l.'; + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |