annotate scripts/control/is_controllable.m @ 3381:69b167451491

[project @ 1999-12-15 20:48:10 by jwe]
author jwe
date Wed, 15 Dec 1999 20:48:45 +0000
parents 8dd4718801fd
children 10f21f7ccc7f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
1 ## Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
2 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
3 ## This file is part of Octave.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
4 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
6 ## under the terms of the GNU General Public License as published by the
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
8 ## later version.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
9 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
13 ## for more details.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
14 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
15 ## You should have received a copy of the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
26
e90ea9cbd4de [project @ 1993-08-10 20:56:55 by jwe]
jwe
parents:
diff changeset
18
3346
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
19 ## -*- texinfo -*-
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
20 ## @deftypefn {Function File } {[@var{retval}, @var{U}] =} is_controllable (@var{sys}@{, @var{tol}@})
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
21 ## @deftypefnx {Function File } {[@var{retval}, @var{U}] =} is_controllable (@var{a}@{, @var{b} ,@var{tol}@})
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
22 ## Logical check for system controllability.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
23 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
24 ## @strong{Inputs}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
25 ## @table @var
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
26 ## @item sys
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
27 ## system data structure
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
28 ## @item a, b
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
29 ## @var{n} by @var{n}, @var{n} by @var{m} matrices, respectively
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
30 ## @item tol
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
31 ## optional roundoff paramter. default value: @code{10*eps}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
32 ## @end table
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
33 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
34 ## @strong{Outputs}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
35 ## @table @var
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
36 ## @item retval
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
37 ## Logical flag; returns true (1) if the system @var{sys} or the
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
38 ## pair (@var{a},@var{b}) is controllable, whichever was passed as input arguments.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
39 ## @item U
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
40 ## U is an orthogonal basis of the controllable subspace.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
41 ## @end table
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
42 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
43 ## @strong{Method}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
44 ## Controllability is determined by applying Arnoldi iteration with
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
45 ## complete re-orthogonalization to obtain an orthogonal basis of the
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
46 ## Krylov subspace
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
47 ## @example
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
48 ## span ([b,a*b,...,a^@{n-1@}*b]).
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
49 ## @end example
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
50 ## The Arnoldi iteration is executed with @code{krylov} if the system has a single input; otherwise a block Arnoldi iteration is performed with @code{krylovb}.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
51 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
52 ## @strong{See also}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
53 ## @code{is_observable}, @code{is_stabilizable}, @code{is_detectable},
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
54 ## @code{krylov}, @code{krylovb}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
55 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
56 ## @end deftypefn
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
57
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
58 ## See also: size, rows, columns, length, is_matrix, is_scalar, is_vector
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
59 ## is_observable, is_stabilizable, is_detectable, krylov, krylovb
26
e90ea9cbd4de [project @ 1993-08-10 20:56:55 by jwe]
jwe
parents:
diff changeset
60
3346
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
61 function [retval,U] = is_controllable (a, b, tol)
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
62
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
63 ## Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
64 ## Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
65 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems
56
3cccff82b7a6 [project @ 1993-08-11 21:49:22 by jwe]
jwe
parents: 26
diff changeset
66
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
67 deftol = 1; # assume default tolerance
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
68 if(nargin < 1 | nargin > 3)
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
69 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b ,tol})", ...
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
70 "is_controllable(sys{,tol})");
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
71 elseif(is_struct(a))
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
72 ## system structure passed.
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
73 sys = sysupdate(a,"ss");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
74 [a,bs] = sys2ss(sys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
75 if(nargin > 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
76 usage("[retval,U] = is_controllable(sys{,tol})");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
77 elseif(nargin == 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
78 tol = b; % get tolerance
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
79 deftol = 0;
26
e90ea9cbd4de [project @ 1993-08-10 20:56:55 by jwe]
jwe
parents:
diff changeset
80 endif
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
81 b = bs;
26
e90ea9cbd4de [project @ 1993-08-10 20:56:55 by jwe]
jwe
parents:
diff changeset
82 else
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
83 ## a,b arguments sent directly.
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
84 if(nargin < 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
85 usage("[retval,U] = is_controllable(a {, b ,tol})");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
86 else
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
87 deftol = 1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
88 endif
26
e90ea9cbd4de [project @ 1993-08-10 20:56:55 by jwe]
jwe
parents:
diff changeset
89 endif
e90ea9cbd4de [project @ 1993-08-10 20:56:55 by jwe]
jwe
parents:
diff changeset
90
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
91 ## check for default tolerance
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
92 if(deftol) tol = 1000*eps; endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
93
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
94 ## check tol dimensions
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
95 if( !is_scalar(tol) )
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
96 error("is_controllable: tol(%dx%d) must be a scalar", ...
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
97 rows(tol),columns(tol));
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
98 elseif( !is_sample(tol) )
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
99 error("is_controllable: tol=%e must be positive",tol);
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
100 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
101
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
102 ## check dimensions compatibility
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
103 n = is_square (a);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
104 [nr, nc] = size (b);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
105
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
106 if (n == 0 | n != nr | nc == 0)
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
107 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc);
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
108 retval = 0;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
109 else
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
110 ## call block-krylov subspace routine to get an orthogonal basis
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
111 ## of the controllable subspace.
3240
2e74d8aa1a20 [project @ 1999-04-07 18:33:23 by jwe]
jwe
parents: 3236
diff changeset
112 [U,H,Ucols] = krylov(a,b,n,tol,1);
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
113 retval = (Ucols == n);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
114 endif
26
e90ea9cbd4de [project @ 1993-08-10 20:56:55 by jwe]
jwe
parents:
diff changeset
115 endfunction