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