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