3213
|
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton |
|
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, 675 Mass Ave, Cambridge, MA 02139, 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 |
3228
|
40 # $Revision: 1.15 $ |
56
|
41 |
3213
|
42 deftol = 1; # assume default tolerance |
|
43 if(nargin < 1 | nargin > 3) |
3228
|
44 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b ,tol})", ... |
|
45 "is_controllable(sys{,tol})"); |
3213
|
46 elseif(is_struct(a)) |
|
47 # system structure passed. |
|
48 sys = sysupdate(a,"ss"); |
|
49 [a,bs] = sys2ss(sys); |
|
50 if(nargin > 2) |
|
51 usage("[retval,U] = is_controllable(sys{,tol})"); |
|
52 elseif(nargin == 2) |
|
53 tol = b; % get tolerance |
|
54 deftol = 0; |
26
|
55 endif |
3213
|
56 b = bs; |
26
|
57 else |
3213
|
58 # a,b arguments sent directly. |
|
59 if(nargin < 2) |
|
60 usage("[retval,U] = is_controllable(a {, b ,tol})"); |
|
61 else |
|
62 deftol = 1; |
|
63 endif |
26
|
64 endif |
|
65 |
3213
|
66 # check for default tolerance |
|
67 if(deftol) tol = 1000*eps; endif |
|
68 |
|
69 # check tol dimensions |
3228
|
70 if( !is_scalar(tol) ) |
|
71 error("is_controllable: tol(%dx%d) must be a scalar", ... |
|
72 rows(tol),columns(tol)); |
|
73 elseif( !is_sample(tol) ) |
|
74 error("is_controllable: tol=%e must be positive",tol); |
3213
|
75 endif |
|
76 |
|
77 # check dimensions compatibility |
|
78 n = is_square (a); |
|
79 [nr, nc] = size (b); |
|
80 |
|
81 if (n == 0 | n != nr | nc == 0) |
3228
|
82 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc); |
3213
|
83 retval = 0; |
|
84 else |
|
85 # call block-krylov subspace routine to get an orthogonal basis |
|
86 # of the controllable subspace. |
|
87 if(nc == 1) |
3228
|
88 [U,H,Ucols] = krylov(a,b,n,tol,1); |
3213
|
89 U = U(:,1:Ucols); |
|
90 else |
|
91 [U,Ucols] = krylovb(a,b,n,tol); |
|
92 U = U(:,1:Ucols); |
|
93 endif |
|
94 |
|
95 retval = (Ucols == n); |
|
96 endif |
26
|
97 endfunction |