3381
|
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 |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
26
|
18 |
3346
|
19 ## -*- texinfo -*- |
|
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}@}) |
|
22 ## Logical check for system controllability. |
|
23 ## |
|
24 ## @strong{Inputs} |
|
25 ## @table @var |
|
26 ## @item sys |
|
27 ## system data structure |
|
28 ## @item a, b |
|
29 ## @var{n} by @var{n}, @var{n} by @var{m} matrices, respectively |
|
30 ## @item tol |
|
31 ## optional roundoff paramter. default value: @code{10*eps} |
|
32 ## @end table |
|
33 ## |
|
34 ## @strong{Outputs} |
|
35 ## @table @var |
|
36 ## @item retval |
|
37 ## Logical flag; returns true (1) if the system @var{sys} or the |
|
38 ## pair (@var{a},@var{b}) is controllable, whichever was passed as input arguments. |
|
39 ## @item U |
|
40 ## U is an orthogonal basis of the controllable subspace. |
|
41 ## @end table |
|
42 ## |
|
43 ## @strong{Method} |
|
44 ## Controllability is determined by applying Arnoldi iteration with |
|
45 ## complete re-orthogonalization to obtain an orthogonal basis of the |
|
46 ## Krylov subspace |
|
47 ## @example |
|
48 ## span ([b,a*b,...,a^@{n-1@}*b]). |
|
49 ## @end example |
|
50 ## The Arnoldi iteration is executed with @code{krylov} if the system has a single input; otherwise a block Arnoldi iteration is performed with @code{krylovb}. |
|
51 ## |
|
52 ## @strong{See also} |
|
53 ## @code{is_observable}, @code{is_stabilizable}, @code{is_detectable}, |
|
54 ## @code{krylov}, @code{krylovb} |
|
55 ## |
|
56 ## @end deftypefn |
|
57 |
3381
|
58 ## See also: size, rows, columns, length, is_matrix, is_scalar, is_vector |
|
59 ## is_observable, is_stabilizable, is_detectable, krylov, krylovb |
26
|
60 |
3346
|
61 function [retval,U] = is_controllable (a, b, tol) |
3381
|
62 |
|
63 ## Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993. |
|
64 ## Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb |
|
65 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems |
56
|
66 |
3213
|
67 deftol = 1; # assume default tolerance |
|
68 if(nargin < 1 | nargin > 3) |
3228
|
69 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b ,tol})", ... |
|
70 "is_controllable(sys{,tol})"); |
3213
|
71 elseif(is_struct(a)) |
3381
|
72 ## system structure passed. |
3213
|
73 sys = sysupdate(a,"ss"); |
|
74 [a,bs] = sys2ss(sys); |
|
75 if(nargin > 2) |
|
76 usage("[retval,U] = is_controllable(sys{,tol})"); |
|
77 elseif(nargin == 2) |
|
78 tol = b; % get tolerance |
|
79 deftol = 0; |
26
|
80 endif |
3213
|
81 b = bs; |
26
|
82 else |
3381
|
83 ## a,b arguments sent directly. |
3213
|
84 if(nargin < 2) |
|
85 usage("[retval,U] = is_controllable(a {, b ,tol})"); |
|
86 else |
|
87 deftol = 1; |
|
88 endif |
26
|
89 endif |
|
90 |
3381
|
91 ## check for default tolerance |
3213
|
92 if(deftol) tol = 1000*eps; endif |
|
93 |
3381
|
94 ## check tol dimensions |
3228
|
95 if( !is_scalar(tol) ) |
|
96 error("is_controllable: tol(%dx%d) must be a scalar", ... |
|
97 rows(tol),columns(tol)); |
|
98 elseif( !is_sample(tol) ) |
|
99 error("is_controllable: tol=%e must be positive",tol); |
3213
|
100 endif |
|
101 |
3381
|
102 ## check dimensions compatibility |
3213
|
103 n = is_square (a); |
|
104 [nr, nc] = size (b); |
|
105 |
|
106 if (n == 0 | n != nr | nc == 0) |
3228
|
107 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc); |
3213
|
108 retval = 0; |
|
109 else |
3381
|
110 ## call block-krylov subspace routine to get an orthogonal basis |
|
111 ## of the controllable subspace. |
3240
|
112 [U,H,Ucols] = krylov(a,b,n,tol,1); |
3213
|
113 retval = (Ucols == n); |
|
114 endif |
26
|
115 endfunction |