annotate scripts/control/system/is_stabilizable.m @ 7016:93c65f2a5668

[project @ 2007-10-12 06:40:56 by jwe]
author jwe
date Fri, 12 Oct 2007 06:41:26 +0000
parents 673686daec87
children a1dbe9d80eee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
1 ## Copyright (C) 1998 Kai P. Mueller.
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
2 ##
3441
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
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
6 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
8 ## your option) any later version.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
9 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
13 ## General Public License for more details.
3441
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
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6653
diff changeset
17 ## <http://www.gnu.org/licenses/>.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
18
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
20 ## @deftypefn {Function File} {@var{retval} =} is_stabilizable (@var{sys}, @var{tol})
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
21 ## @deftypefnx {Function File} {@var{retval} =} is_stabilizable (@var{a}, @var{b}, @var{tol}, @var{dflg})
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
22 ## Logical check for system stabilizability (i.e., all unstable modes are controllable).
6653
673686daec87 [project @ 2007-05-22 15:36:09 by jwe]
jwe
parents: 6046
diff changeset
23 ## Returns 1 if the system is stabilizable, 0 if the system is not stabilizable, -1
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
24 ## if the system has non stabilizable modes at the imaginary axis (unit circle for
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
25 ## discrete-time systems.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
26 ##
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
27 ## Test for stabilizability is performed via Hautus Lemma. If
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
28 ## @iftex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
29 ## @tex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
30 ## @var{dflg}$\neq$0
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
31 ## @end tex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
32 ## @end iftex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
33 ## @ifinfo
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
34 ## @var{dflg}!=0
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
35 ## @end ifinfo
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
36 ## assume that discrete-time matrices (a,b) are supplied.
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
37 ## @seealso{size, rows, columns, length, ismatrix, isscalar, isvector
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4611
diff changeset
38 ## is_observable, is_stabilizable, is_detectable}
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5307
diff changeset
39 ## @end deftypefn
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
40
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
41 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu>
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
42 ## Created: August 1993
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
43 ## 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
44 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 to accept systems
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
45
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
46 function retval = is_stabilizable (a, b, tol, dflg)
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
47
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
48 if(nargin < 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
49 print_usage ();
4030
22bd65326ec1 [project @ 2002-08-09 18:58:13 by jwe]
jwe
parents: 3814
diff changeset
50 elseif(isstruct(a))
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
51 ## system passed.
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
52 if(nargin == 2)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
53 tol = b; % get tolerance
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
54 elseif(nargin > 2)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
55 print_usage ();
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
56 endif
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
57 disc = is_digital(a);
3814
fb01838d0f38 [project @ 2001-04-19 02:26:07 by jwe]
jwe
parents: 3502
diff changeset
58 [a,b] = sys2ss(a);
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
59 else
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
60 ## a,b arguments sent directly.
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
61 if ((nargin > 4)||(nargin == 1))
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
62 print_usage ();
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
63 endif
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
64 if(exist("dflg"))
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
65 disc = dflg;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
66 else
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
67 disc = 0;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
68 end
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
69 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
70
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
71 if(~exist("tol"))
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
72 tol = 200*eps;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
73 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
74
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
75
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
76 ## Checking dimensions
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
77 n = is_square(a);
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
78 if (n==0)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
79 error("is_stabilizable: a must be square");
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
80 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
81 [nr,m] = size(b);
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
82 if (nr!=n)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
83 error("is_stabilizable: (a,b) not conformal");
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
84 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
85
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
86 ##Computing the eigenvalue of A
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
87 L = eig(a);
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
88 retval = 1;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
89 specflag = 0;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
90 for i=1:n
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
91 if (disc==0)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
92 ## Continuous time case
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
93 rL = real(L(i));
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
94 if (rL>=0)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
95 H = [eye(n)*L(i)-a, b];
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
96 f = (rank(H,tol)==n);
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
97 if (f==0)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
98 retval = 0;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
99 if (rL==0)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
100 specflag = 1;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
101 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
102 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
103 end
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
104 else
4611
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
105 ## Discrete time case
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
106 rL = abs(L(i));
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
107 if (rL>=1)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
108 H = [eye(n)*L(i)-a, b];
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
109 f = (rank(H,tol)==n);
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
110 if (f==0)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
111 retval = 0;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
112 if (rL==1)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
113 specflag = 1;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
114 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
115 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
116 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
117 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
118 end
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
119 if (specflag==1)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
120 ## This means that the system has uncontrollable modes at the imaginary axis
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
121 ## (or at the unit circle for discrete time systems)
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
122 retval = -1;
c76a32c6f90c [project @ 2003-11-14 17:48:46 by jwe]
jwe
parents: 4030
diff changeset
123 end