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 |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
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 |
|
33 ## optional roundoff paramter. default value: @code{10*eps} |
|
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}. |
|
56 ## @end deftypefn |
5053
|
57 ## |
4030
|
58 ## @seealso{size, rows, columns, length, ismatrix, isscalar, isvector |
3441
|
59 ## is_observable, is_stabilizable, is_detectable, krylov, and krylovb} |
|
60 |
|
61 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
62 ## Created: August 1993 |
|
63 ## Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb |
|
64 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems |
|
65 |
|
66 function [retval, U] = is_controllable (a, b, tol) |
|
67 |
|
68 deftol = 1; # assume default tolerance |
|
69 if(nargin < 1 | nargin > 3) |
|
70 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b, tol})", ... |
|
71 "is_controllable(sys{,tol})"); |
4030
|
72 elseif(isstruct(a)) |
3441
|
73 ## system structure passed. |
|
74 sys = sysupdate(a,"ss"); |
|
75 [a,bs] = sys2ss(sys); |
|
76 if(nargin > 2) |
|
77 usage("[retval,U] = is_controllable(sys{,tol})"); |
|
78 elseif(nargin == 2) |
|
79 tol = b; % get tolerance |
|
80 deftol = 0; |
|
81 endif |
|
82 b = bs; |
|
83 else |
|
84 ## a,b arguments sent directly. |
|
85 if(nargin < 2) |
|
86 usage("[retval,U] = is_controllable(a {, b ,tol})"); |
|
87 else |
|
88 deftol = 1; |
|
89 endif |
|
90 endif |
|
91 |
|
92 ## check for default tolerance |
|
93 if(deftol) tol = 1000*eps; endif |
|
94 |
|
95 ## check tol dimensions |
4030
|
96 if( !isscalar(tol) ) |
3441
|
97 error("is_controllable: tol(%dx%d) must be a scalar", ... |
|
98 rows(tol),columns(tol)); |
|
99 elseif( !is_sample(tol) ) |
|
100 error("is_controllable: tol=%e must be positive",tol); |
|
101 endif |
|
102 |
|
103 ## check dimensions compatibility |
4030
|
104 n = issquare (a); |
3441
|
105 [nr, nc] = size (b); |
|
106 |
|
107 if (n == 0 | n != nr | nc == 0) |
|
108 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc); |
|
109 retval = 0; |
|
110 else |
|
111 ## call block-krylov subspace routine to get an orthogonal basis |
|
112 ## of the controllable subspace. |
|
113 [U,H,Ucols] = krylov(a,b,n,tol,1); |
|
114 retval = (Ucols == n); |
|
115 endif |
|
116 endfunction |