26
|
1 function retval = is_controllable (a,b,tol) |
|
2 |
|
3 # usage: is_controllable (a,b{,tol}) |
|
4 # |
|
5 # returns 1 the pair(a,b) is controllable, then return value is the |
|
6 # dimension of x. 0therwise, returns a value of 0 |
|
7 # |
|
8 # See also: size, rows, columns, length, is_matrix, is_scalar, is_vector |
|
9 |
|
10 # This should really use the method below, but I'm being lazy for now: |
|
11 # |
|
12 # Controllability is determined by applying Arnoldi iteration with complete |
|
13 # re-orthogonalization to obtain an orthogonal basis of the Krylov subspace |
|
14 # n-1 |
|
15 # span([b,a*b,...,a^ b]). tol is a roundoff paramter, |
|
16 # set to 2*eps if omitted |
|
17 |
|
18 if ((nargin == 2) || (nargin == 3)) |
|
19 n = is_square(a); |
|
20 [nr, nc] = size (b); |
|
21 if((n == 0) || (n != nr) || (nc == 0)) |
|
22 retval = 0; |
|
23 else |
|
24 |
|
25 m = b; |
|
26 tmp = b; |
|
27 for ii=1:(n-1) |
|
28 tmp = a*tmp; |
|
29 m = [m,tmp]; |
|
30 endfor |
|
31 |
|
32 # if n is of any significant size, m will be low rank, so be careful! |
|
33 if(nargin == 3) |
|
34 if(is_scalar(tol)) |
|
35 retval = (rank(m,tol) == n); |
|
36 else |
|
37 error('is_controllable: tol must be a scalar') |
|
38 endif |
|
39 else |
|
40 retval = (rank(m) == n); |
|
41 endif |
|
42 endif |
|
43 else |
|
44 error ("usage: is_controllable (a,b)"); |
|
45 endif |
|
46 |
|
47 endfunction |