annotate scripts/control/system/is_controllable.m @ 5642:2618a0750ae6

[project @ 2006-03-06 21:26:48 by jwe]
author jwe
date Mon, 06 Mar 2006 21:26:54 +0000
parents 66ad03c58880
children 34f96dd5441b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1993, 1994, 1995 Auburn University. All rights reserved.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
2 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
4 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by the
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
8 ## later version.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
9 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
13 ## for more details.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
14 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5053
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5053
diff changeset
18 ## 02110-1301 USA.
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)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
69 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b, tol})", ...
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
70 "is_controllable(sys{,tol})");
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3502
diff changeset
71 elseif(isstruct(a))
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
72 ## system structure passed.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
73 sys = sysupdate(a,"ss");
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
74 [a,bs] = sys2ss(sys);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
75 if(nargin > 2)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
76 usage("[retval,U] = is_controllable(sys{,tol})");
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
77 elseif(nargin == 2)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
78 tol = b; % get tolerance
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
79 deftol = 0;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
80 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
81 b = bs;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
82 else
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
83 ## a,b arguments sent directly.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
84 if(nargin < 2)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
85 usage("[retval,U] = is_controllable(a {, b ,tol})");
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
86 else
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
87 deftol = 1;
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 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
90
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
91 ## check for default tolerance
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
92 if(deftol) tol = 1000*eps; endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
93
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
94 ## check tol dimensions
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3502
diff changeset
95 if( !isscalar(tol) )
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
96 error("is_controllable: tol(%dx%d) must be a scalar", ...
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
97 rows(tol),columns(tol));
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
98 elseif( !is_sample(tol) )
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
99 error("is_controllable: tol=%e must be positive",tol);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
100 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
101
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
102 ## check dimensions compatibility
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3502
diff changeset
103 n = issquare (a);
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
104 [nr, nc] = size (b);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
105
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
106 if (n == 0 | n != nr | nc == 0)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
107 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
108 retval = 0;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
109 else
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
110 ## call block-krylov subspace routine to get an orthogonal basis
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
111 ## of the controllable subspace.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
112 [U,H,Ucols] = krylov(a,b,n,tol,1);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
113 retval = (Ucols == n);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
114 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
115 endfunction