7017
|
1 ## Copyright (C) 1993, 1994, 1995, 2000, 2002, 2004, 2005, 2006, 2007 |
|
2 ## Auburn University. All rights reserved. |
3441
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3441
|
10 ## |
7016
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
3441
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3441
|
19 |
|
20 ## -*- texinfo -*- |
3502
|
21 ## @deftypefn {Function File} {[@var{retval}, @var{u}] =} is_controllable (@var{sys}, @var{tol}) |
|
22 ## @deftypefnx {Function File} {[@var{retval}, @var{u}] =} is_controllable (@var{a}, @var{b}, @var{tol}) |
3441
|
23 ## Logical check for system controllability. |
|
24 ## |
|
25 ## @strong{Inputs} |
|
26 ## @table @var |
|
27 ## @item sys |
|
28 ## system data structure |
|
29 ## @item a |
|
30 ## @itemx b |
|
31 ## @var{n} by @var{n}, @var{n} by @var{m} matrices, respectively |
|
32 ## @item tol |
5435
|
33 ## optional roundoff parameter. Default value: @code{10*eps} |
3441
|
34 ## @end table |
|
35 ## |
|
36 ## @strong{Outputs} |
|
37 ## @table @var |
|
38 ## @item retval |
|
39 ## Logical flag; returns true (1) if the system @var{sys} or the |
4855
|
40 ## pair (@var{a}, @var{b}) is controllable, whichever was passed as input |
3441
|
41 ## arguments. |
5016
|
42 ## @item u |
|
43 ## @var{u} is an orthogonal basis of the controllable subspace. |
3441
|
44 ## @end table |
|
45 ## |
|
46 ## @strong{Method} |
|
47 ## Controllability is determined by applying Arnoldi iteration with |
|
48 ## complete re-orthogonalization to obtain an orthogonal basis of the |
|
49 ## Krylov subspace |
|
50 ## @example |
|
51 ## span ([b,a*b,...,a^@{n-1@}*b]). |
|
52 ## @end example |
|
53 ## The Arnoldi iteration is executed with @code{krylov} if the system |
|
54 ## has a single input; otherwise a block Arnoldi iteration is performed |
|
55 ## with @code{krylovb}. |
5642
|
56 ## @seealso{size, rows, columns, length, ismatrix, isscalar, isvector |
|
57 ## is_observable, is_stabilizable, is_detectable, krylov, krylovb} |
3441
|
58 ## @end deftypefn |
|
59 |
|
60 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
61 ## Created: August 1993 |
|
62 ## Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb |
|
63 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems |
|
64 |
|
65 function [retval, U] = is_controllable (a, b, tol) |
|
66 |
|
67 deftol = 1; # assume default tolerance |
7136
|
68 |
|
69 if (nargin < 1 || nargin > 3) |
6046
|
70 print_usage (); |
7136
|
71 elseif (isstruct (a)) |
3441
|
72 ## system structure passed. |
7136
|
73 sys = sysupdate (a, "ss"); |
|
74 [a, bs] = sys2ss (sys); |
|
75 if (nargin > 2) |
6046
|
76 print_usage (); |
7136
|
77 elseif (nargin == 2) |
3441
|
78 tol = b; % get tolerance |
|
79 deftol = 0; |
|
80 endif |
|
81 b = bs; |
|
82 else |
|
83 ## a,b arguments sent directly. |
7136
|
84 if (nargin < 2) |
6046
|
85 print_usage (); |
3441
|
86 else |
|
87 deftol = 1; |
|
88 endif |
|
89 endif |
|
90 |
|
91 ## check for default tolerance |
7136
|
92 if (deftol) |
|
93 tol = 1000*eps; |
|
94 endif |
3441
|
95 |
|
96 ## check tol dimensions |
7136
|
97 if (! isscalar (tol)) |
|
98 error ("is_controllable: tol(%dx%d) must be a scalar", ... |
|
99 rows (tol), columns (tol)); |
|
100 elseif (! is_sample (tol)) |
|
101 error ("is_controllable: tol=%e must be positive",tol); |
3441
|
102 endif |
|
103 |
|
104 ## check dimensions compatibility |
4030
|
105 n = issquare (a); |
3441
|
106 [nr, nc] = size (b); |
|
107 |
7136
|
108 if (n == 0 || n != nr || nc == 0) |
|
109 warning ("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc); |
3441
|
110 retval = 0; |
|
111 else |
|
112 ## call block-krylov subspace routine to get an orthogonal basis |
|
113 ## of the controllable subspace. |
7136
|
114 [U, H, Ucols] = krylov (a, b, n, tol, 1); |
3441
|
115 retval = (Ucols == n); |
|
116 endif |
7136
|
117 |
3441
|
118 endfunction |