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 |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
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 |
|
32 ## optional roundoff paramter. default value: @code{10*eps} |
|
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 |
|
39 ## pair (@var{a},@var{b}) is controllable, whichever was passed as input |
|
40 ## arguments. |
|
41 ## @item U |
|
42 ## U is an orthogonal basis of the controllable subspace. |
|
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}. |
|
55 ## @end deftypefn |
|
56 ## @seealso{size, rows, columns, length, is_matrix, is_scalar, is_vector |
|
57 ## is_observable, is_stabilizable, is_detectable, krylov, and krylovb} |
|
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) |
|
68 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b, tol})", ... |
|
69 "is_controllable(sys{,tol})"); |
|
70 elseif(is_struct(a)) |
|
71 ## system structure passed. |
|
72 sys = sysupdate(a,"ss"); |
|
73 [a,bs] = sys2ss(sys); |
|
74 if(nargin > 2) |
|
75 usage("[retval,U] = is_controllable(sys{,tol})"); |
|
76 elseif(nargin == 2) |
|
77 tol = b; % get tolerance |
|
78 deftol = 0; |
|
79 endif |
|
80 b = bs; |
|
81 else |
|
82 ## a,b arguments sent directly. |
|
83 if(nargin < 2) |
|
84 usage("[retval,U] = is_controllable(a {, b ,tol})"); |
|
85 else |
|
86 deftol = 1; |
|
87 endif |
|
88 endif |
|
89 |
|
90 ## check for default tolerance |
|
91 if(deftol) tol = 1000*eps; endif |
|
92 |
|
93 ## check tol dimensions |
|
94 if( !is_scalar(tol) ) |
|
95 error("is_controllable: tol(%dx%d) must be a scalar", ... |
|
96 rows(tol),columns(tol)); |
|
97 elseif( !is_sample(tol) ) |
|
98 error("is_controllable: tol=%e must be positive",tol); |
|
99 endif |
|
100 |
|
101 ## check dimensions compatibility |
|
102 n = is_square (a); |
|
103 [nr, nc] = size (b); |
|
104 |
|
105 if (n == 0 | n != nr | nc == 0) |
|
106 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc); |
|
107 retval = 0; |
|
108 else |
|
109 ## call block-krylov subspace routine to get an orthogonal basis |
|
110 ## of the controllable subspace. |
|
111 [U,H,Ucols] = krylov(a,b,n,tol,1); |
|
112 retval = (Ucols == n); |
|
113 endif |
|
114 endfunction |