2313
|
1 ## Copyright (C) 1996 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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License 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 |
|
18 ## 02111-1307, USA. |
245
|
19 |
2311
|
20 ## Usage: is_controllable (a, b {,tol}) |
|
21 ## |
|
22 ## Returns 1 if the pair (a, b) is controllable, or 0 if not. |
|
23 ## |
|
24 ## See also: size, rows, columns, length, is_matrix, is_scalar, is_vector |
|
25 ## |
|
26 ## This should really use the method below, but I'm being lazy for now: |
|
27 ## |
|
28 ## Controllability is determined by applying Arnoldi iteration with |
|
29 ## complete re-orthogonalization to obtain an orthogonal basis of the |
|
30 ## Krylov subspace. |
|
31 ## |
|
32 ## (FIX ME... The Krylov subspace approach is not done yet!) |
|
33 ## n-1 |
|
34 ## span ([b,a*b,...,a^ b]). |
|
35 ## |
|
36 ## tol is a roundoff paramter, set to 2*eps if omitted. |
26
|
37 |
2312
|
38 ## Author: A. S. Hodel <scotte@eng.auburn.edu> |
|
39 ## Created: August 1993 |
|
40 ## Adapted-By: jwe |
73
|
41 |
2312
|
42 function retval = is_controllable (a, b, tol) |
26
|
43 |
56
|
44 if (nargin == 2 || nargin == 3) |
|
45 |
|
46 n = is_square (a); |
26
|
47 [nr, nc] = size (b); |
56
|
48 |
|
49 if (n == 0 || n != nr || nc == 0) |
26
|
50 retval = 0; |
|
51 else |
|
52 |
|
53 m = b; |
|
54 tmp = b; |
56
|
55 for ii = 1:(n-1) |
|
56 tmp = a * tmp; |
|
57 m = [m, tmp]; |
26
|
58 endfor |
|
59 |
2303
|
60 ## If n is of any significant size, m will be low rank, so be careful! |
56
|
61 |
|
62 if (nargin == 3) |
|
63 if (is_scalar (tol)) |
|
64 retval = (rank (m, tol) == n); |
26
|
65 else |
56
|
66 error ("is_controllable: tol must be a scalar"); |
26
|
67 endif |
|
68 else |
56
|
69 retval = (rank (m) == n); |
26
|
70 endif |
|
71 endif |
|
72 else |
904
|
73 usage ("is_controllable (a, b)"); |
26
|
74 endif |
|
75 |
|
76 endfunction |