1 ## Copyright (C) 2010 Benjamin Fernandez
2 ## Copyright (C) 2011 Lukas F. Reichlin
4 ## This file is part of LTI Syncope.
6 ## LTI Syncope is free software: you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, either version 3 of the License, or
9 ## (at your option) any later version.
11 ## LTI Syncope is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>.
20 ## @deftypefn{Function File} {[@var{sysbar}, @var{T}, @var{K}] =} ctrbf (@var{sys})
21 ## @deftypefnx{Function File} {[@var{sysbar}, @var{T}, @var{K}] =} ctrbf (@var{sys}, @var{tol})
22 ## @deftypefnx{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} ctrbf (@var{A}, @var{B}, @var{C})
23 ## @deftypefnx{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} ctrbf (@var{A}, @var{B}, @var{C}, @var{TOL})
24 ## If Co=ctrb(A,B) has rank r <= n = SIZE(A,1), then there is a
25 ## similarity transformation Tc such that Tc = [t1 t2] where t1
26 ## is the controllable subspace and t2 is orthogonal to t1
30 ## Abar = Tc \ A * Tc , Bbar = Tc \ B , Cbar = C * Tc
34 ## and the transformed system has the form
39 ## Abar = |----------|, Bbar = | ---|, Cbar = [Cc | Cnc].
44 ## where (Ac,Bc) is controllable, and Cc(sI-Ac)^(-1)Bc = C(sI-A)^(-1)B.
45 ## and the system is stabilizable if Anc has no eigenvalues in
46 ## the right half plane. The last output K is a vector of length n
47 ## containing the number of controllable states.
50 ## Author: Benjamin Fernandez <mail@benjaminfernandez.info>
51 ## Created: 2010-04-30
54 function [ac, bc, cc, z, ncont] = ctrbf (a, b = [], c, tol = [])
56 if (nargin < 1 || nargin > 4)
60 islti = isa (a, "lti");
68 [a, b, c] = ssdata (sys);
74 [a, b, c] = ssdata (sys);
78 tol = 0; # default tolerance
79 elseif (! is_real_scalar (tol))
80 error ("ctrbf: tol must be a real scalar");
83 [ac, bc, cc, z, ncont] = sltb01ud (a, b, c, tol);
86 ac = set (sys, "a", ac, "b", bc, "c", cc, "scaled", false);
93 %!shared Ao, Bo, Co, Zo, Ae, Be, Ce, Ze, NCONT
104 %! [Ao, Bo, Co, Zo, NCONT] = ctrbf (A, B, C);
106 %! Ae = [ -3.0000 2.2361
109 %! Be = [ 0.0000 -2.2361
112 %! Ce = [ -2.2361 0.0000
115 %! Ze = [ 0.0000 1.0000 0.0000
116 %! -0.8944 0.0000 -0.4472
117 %! -0.4472 0.0000 0.8944 ];
119 %!assert (Ao(1:NCONT, 1:NCONT), Ae, 1e-4);
120 %!assert (Bo(1:NCONT, :), Be, 1e-4);
121 %!assert (Co(:, 1:NCONT), Ce, 1e-4);
122 %!assert (Zo, Ze, 1e-4);