annotate scripts/control/system/is_controllable.m @ 7017:a1dbe9d80eee

[project @ 2007-10-12 21:27:11 by jwe]
author jwe
date Fri, 12 Oct 2007 21:27:37 +0000
parents 93c65f2a5668
children 59dcf01bb3e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 1993, 1994, 1995, 2000, 2002, 2004, 2005, 2006, 2007
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
2 ## Auburn University. All rights reserved.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
3 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
4 ## This file is part of Octave.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
5 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
9 ## your option) any later version.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
10 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
14 ## General Public License for more details.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
15 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
18 ## <http://www.gnu.org/licenses/>.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
19
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
3502
b5238ac1dca9 [project @ 2000-01-31 07:40:53 by jwe]
jwe
parents: 3500
diff changeset
21 ## @deftypefn {Function File} {[@var{retval}, @var{u}] =} is_controllable (@var{sys}, @var{tol})
b5238ac1dca9 [project @ 2000-01-31 07:40:53 by jwe]
jwe
parents: 3500
diff changeset
22 ## @deftypefnx {Function File} {[@var{retval}, @var{u}] =} is_controllable (@var{a}, @var{b}, @var{tol})
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
23 ## Logical check for system controllability.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
24 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
25 ## @strong{Inputs}
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
26 ## @table @var
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
27 ## @item sys
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
28 ## system data structure
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
29 ## @item a
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
30 ## @itemx b
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
31 ## @var{n} by @var{n}, @var{n} by @var{m} matrices, respectively
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
32 ## @item tol
5435
66ad03c58880 [project @ 2005-08-31 20:41:47 by jwe]
jwe
parents: 5307
diff changeset
33 ## optional roundoff parameter. Default value: @code{10*eps}
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
34 ## @end table
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
35 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
36 ## @strong{Outputs}
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
37 ## @table @var
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
38 ## @item retval
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
39 ## Logical flag; returns true (1) if the system @var{sys} or the
4855
d62c421f448b [project @ 2004-04-07 02:41:22 by jwe]
jwe
parents: 4030
diff changeset
40 ## pair (@var{a}, @var{b}) is controllable, whichever was passed as input
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
41 ## arguments.
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4855
diff changeset
42 ## @item u
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4855
diff changeset
43 ## @var{u} is an orthogonal basis of the controllable subspace.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
44 ## @end table
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
45 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
46 ## @strong{Method}
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
47 ## Controllability is determined by applying Arnoldi iteration with
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
48 ## complete re-orthogonalization to obtain an orthogonal basis of the
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
49 ## Krylov subspace
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
50 ## @example
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
51 ## span ([b,a*b,...,a^@{n-1@}*b]).
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
52 ## @end example
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
53 ## The Arnoldi iteration is executed with @code{krylov} if the system
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
54 ## has a single input; otherwise a block Arnoldi iteration is performed
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
55 ## with @code{krylovb}.
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5435
diff changeset
56 ## @seealso{size, rows, columns, length, ismatrix, isscalar, isvector
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5435
diff changeset
57 ## is_observable, is_stabilizable, is_detectable, krylov, krylovb}
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
58 ## @end deftypefn
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
59
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
60 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu>
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
61 ## Created: August 1993
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
62 ## Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
63 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
64
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
65 function [retval, U] = is_controllable (a, b, tol)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
66
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
67 deftol = 1; # assume default tolerance
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
68 if(nargin < 1 | nargin > 3)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
69 print_usage ();
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3502
diff changeset
70 elseif(isstruct(a))
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
71 ## system structure passed.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
72 sys = sysupdate(a,"ss");
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
73 [a,bs] = sys2ss(sys);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
74 if(nargin > 2)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
75 print_usage ();
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
76 elseif(nargin == 2)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
77 tol = b; % get tolerance
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
78 deftol = 0;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
79 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
80 b = bs;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
81 else
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
82 ## a,b arguments sent directly.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
83 if(nargin < 2)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
84 print_usage ();
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
85 else
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
86 deftol = 1;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
87 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
88 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
89
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
90 ## check for default tolerance
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
91 if(deftol) tol = 1000*eps; endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
92
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
93 ## check tol dimensions
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3502
diff changeset
94 if( !isscalar(tol) )
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
95 error("is_controllable: tol(%dx%d) must be a scalar", ...
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
96 rows(tol),columns(tol));
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
97 elseif( !is_sample(tol) )
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
98 error("is_controllable: tol=%e must be positive",tol);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
99 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
100
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
101 ## check dimensions compatibility
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3502
diff changeset
102 n = issquare (a);
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
103 [nr, nc] = size (b);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
104
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
105 if (n == 0 | n != nr | nc == 0)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
106 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
107 retval = 0;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
108 else
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
109 ## call block-krylov subspace routine to get an orthogonal basis
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
110 ## of the controllable subspace.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
111 [U,H,Ucols] = krylov(a,b,n,tol,1);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
112 retval = (Ucols == n);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
113 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
114 endfunction