3279
|
1 # Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved |
3213
|
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 |
3284
|
17 # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
26
|
18 |
3213
|
19 function [retval,U] = is_controllable (a, b, tol) |
|
20 # [retval, U] = is_controllable (a, b {,tol}) |
|
21 # = is_controllable (sys{, tol}) |
|
22 # Returns retval=1 if the system sys or the pair (a, b) is controllable |
|
23 # 0 if not. |
|
24 # U is an orthogonal basis of the controllable subspace. |
|
25 # |
|
26 # Controllability is determined by applying Arnoldi iteration with |
|
27 # complete re-orthogonalization to obtain an orthogonal basis of the |
|
28 # Krylov subspace. |
|
29 # |
|
30 # span ([b,a*b,...,a^ b]). |
|
31 # |
|
32 # tol is a roundoff paramter, set to 10*eps if omitted. |
|
33 # |
|
34 # See also: size, rows, columns, length, is_matrix, is_scalar, is_vector |
|
35 # is_observable, is_stabilizable, is_detectable, krylov, krylovb |
26
|
36 |
3213
|
37 # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993. |
|
38 # Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb |
|
39 # Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems |
56
|
40 |
3213
|
41 deftol = 1; # assume default tolerance |
|
42 if(nargin < 1 | nargin > 3) |
3228
|
43 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b ,tol})", ... |
|
44 "is_controllable(sys{,tol})"); |
3213
|
45 elseif(is_struct(a)) |
|
46 # system structure passed. |
|
47 sys = sysupdate(a,"ss"); |
|
48 [a,bs] = sys2ss(sys); |
|
49 if(nargin > 2) |
|
50 usage("[retval,U] = is_controllable(sys{,tol})"); |
|
51 elseif(nargin == 2) |
|
52 tol = b; % get tolerance |
|
53 deftol = 0; |
26
|
54 endif |
3213
|
55 b = bs; |
26
|
56 else |
3213
|
57 # a,b arguments sent directly. |
|
58 if(nargin < 2) |
|
59 usage("[retval,U] = is_controllable(a {, b ,tol})"); |
|
60 else |
|
61 deftol = 1; |
|
62 endif |
26
|
63 endif |
|
64 |
3213
|
65 # check for default tolerance |
|
66 if(deftol) tol = 1000*eps; endif |
|
67 |
|
68 # check tol dimensions |
3228
|
69 if( !is_scalar(tol) ) |
|
70 error("is_controllable: tol(%dx%d) must be a scalar", ... |
|
71 rows(tol),columns(tol)); |
|
72 elseif( !is_sample(tol) ) |
|
73 error("is_controllable: tol=%e must be positive",tol); |
3213
|
74 endif |
|
75 |
|
76 # check dimensions compatibility |
|
77 n = is_square (a); |
|
78 [nr, nc] = size (b); |
|
79 |
|
80 if (n == 0 | n != nr | nc == 0) |
3228
|
81 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc); |
3213
|
82 retval = 0; |
|
83 else |
|
84 # call block-krylov subspace routine to get an orthogonal basis |
|
85 # of the controllable subspace. |
3240
|
86 [U,H,Ucols] = krylov(a,b,n,tol,1); |
3213
|
87 retval = (Ucols == n); |
|
88 endif |
26
|
89 endfunction |