From: <par...@us...> - 2010-05-02 17:47:49
|
Revision: 7283 http://octave.svn.sourceforge.net/octave/?rev=7283&view=rev Author: paramaniac Date: 2010-05-02 17:47:43 +0000 (Sun, 02 May 2010) Log Message: ----------- control: add ctrbf.m and obsvf.m (thanks to Benjamin Fernandez) Added Paths: ----------- trunk/octave-forge/main/control/inst/ctrbf.m trunk/octave-forge/main/control/inst/obsvf.m Added: trunk/octave-forge/main/control/inst/ctrbf.m =================================================================== --- trunk/octave-forge/main/control/inst/ctrbf.m (rev 0) +++ trunk/octave-forge/main/control/inst/ctrbf.m 2010-05-02 17:47:43 UTC (rev 7283) @@ -0,0 +1,76 @@ +## Copyright (C) 2010 Benjamin Fernandez <ma...@be...> +## +## This program 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 2 of the License, or +## (at your option) any later version. +## +## This program 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 Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} ctrbf (@var{A}, @var{B}, @var{C}) +## @deftypefnx{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} ctrbf (@var{A}, @var{B}, @var{C}, @var{TOL}) +## If Co=ctrb(A,B) has rank r <= n = SIZE(A,1), then there is a +## similarity transformation Tc such that Tc = [t1 t2] where t1 +## is the controlable subspace and t2 is orthogonal to t1 +## +## @example +## @group +## Abar = Tc \ A * Tc , Bbar = Tc \ B , Cbar = C * Tc +## @end group +## @end example +## +## and the transformed system has the form +## +## @example +## @group +## | Ac A12| | Bc | +## Abar = |----------|, Bbar = | ---|, Cbar = [Cc | Cnc]. +## | 0 Anc| | 0 | +## @end group +## @end example +## +## where (Ac,Bc) is controllable, and Cc(sI-Ac)^(-1)Bc = C(sI-A)^(-1)B. +## and the system is stabilizable if Anc has no eigenvalues in +## the right half plane. The last output K is a vector of length n +## containing the number of controllable states. +## @end deftypefn + +## Author: Benjamin Fernandez <benjas@benjas-laptop> +## Created: 2010-04-30 + +function [Abar, Bbar, Cbar, T, K] = ctrbf (A, B, C, TOL) + + if (nargin<3 || nargin>4) + print_usage (); + end + + n = length (A); + + if (nargin==3) + TOL = n*norm (A,1)*eps; + end + + Co = ctrb (A, B); + [nrc, ncc] = size (Co); + rco = rank (Co,TOL); + lr = nrc-rco; + [U, S, V] = svd (Co); + K = U(:, 1:rco); # Basis column space + T = U; # [B orth(B)] + Abar = T\A*T; + Bbar = T\B; + Cbar = C*T; + Anc = Abar(n-(n-rco)+1:n, n-(n-rco)+1:n); + Ac = Abar(1:rco, 1:rco); + Bc = Bbar(1:rco, :); + Cc = Cbar(:, 1:rco); + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/obsvf.m =================================================================== --- trunk/octave-forge/main/control/inst/obsvf.m (rev 0) +++ trunk/octave-forge/main/control/inst/obsvf.m 2010-05-02 17:47:43 UTC (rev 7283) @@ -0,0 +1,76 @@ +## Copyright (C) 2010 Benjamin Fernandez +## +## This program 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 2 of the License, or +## (at your option) any later version. +## +## This program 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 Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} obsvf (@var{A}, @var{B}, @var{C}) +## @deftypefnx{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} obsvf (@var{A}, @var{B}, @var{C}, @var{TOL}) +## If Ob=obsv(A,C) has rank r <= n = SIZE(A,1), then there is a +## similarity transformation Tc such that To = [t1;t2] where t1 is c +## and t2 is orthogonal to t1 +## +## @example +## @group +## Abar = To \ A * To , Bbar = To \ B , Cbar = C * To +## @end group +## @end example +## +## and the transformed system has the form +## +## @example +## @group +## | Ao 0 | | Bo | +## Abar = |----------|, Bbar = | --- |, Cbar = [Co | 0 ]. +## | A21 Ano| | Bno | +## @end group +## @end example +## +## where (Ao,Bo) is observable, and Co(sI-Ao)^(-1)Bo = C(sI-A)^(-1)B. And +## system is detectable if Ano has no eigenvalues in the right +## half plane. The last output K is a vector of length n containing the +## number of observable states. +## @end deftypefn + +## Author: Benjamin Fernandez <benjas@benjas-laptop> +## Created: 2010-05-02 + +function [Abar, Bbar, Cbar, T, K] = obsvf (A, B, C, TOL) + + if (nargin<3 || nargin>4) + print_usage (); + end + + n = length (A); + + if (nargin==3) + TOL = n*norm (A, 1)*eps; + end + + Ob = obsv (A, C); + [nro, nco] = size (Ob); + rob = rank (Ob); + lr = nco-rob; + [U, S, V] = svd (Ob); + K = V(:, 1:rob); # Basis raw space + T = V; # [c;orth(c)]; + Abar = T\A*T; + Bbar = T\B; + Cbar = C*T; + Ano = Abar(n-(n-rob)+1:n, n-(n-rob)+1:n) + Ao = Abar(1:rob, 1:rob); + Bo = Bbar(1:rob, :); + Co = Cbar(:, 1:rob); + +endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |