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