3441
|
1 ## Copyright (C) 1993, 1994, 1995 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3441
|
19 |
|
20 ## -*- texinfo -*- |
3500
|
21 ## @deftypefn {Function File} {} is_stable (@var{a}, @var{tol}, @var{dflg}) |
|
22 ## @deftypefnx {Function File} {} is_stable (@var{sys}, @var{tol}) |
|
23 ## Returns 1 if the matrix @var{a} or the system @var{sys} |
3441
|
24 ## is stable, or 0 if not. |
|
25 ## |
|
26 ## @strong{Inputs} |
|
27 ## @table @var |
|
28 ## @item tol |
5016
|
29 ## is a roundoff parameter, set to 200*@code{eps} if omitted. |
3441
|
30 ## @item dflg |
|
31 ## Digital system flag (not required for system data structure): |
|
32 ## @table @code |
|
33 ## @item @var{dflg} != 0 |
5016
|
34 ## stable if eig(a) is in the unit circle |
3441
|
35 ## |
|
36 ## @item @var{dflg} == 0 |
5016
|
37 ## stable if eig(a) is in the open LHP (default) |
3441
|
38 ## @end table |
|
39 ## @end table |
|
40 ## @end deftypefn |
5053
|
41 ## |
4030
|
42 ## @seealso{size, rows, columns, length, ismatrix, isscalar, isvector |
3441
|
43 ## is_observable, is_stabilizable, is_detectable, krylov, and krylovb} |
|
44 |
|
45 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
46 ## Created: August 1993 |
|
47 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for systems |
|
48 ## Updated to simpler form by a.s.hodel 1998 |
|
49 |
|
50 function retval = is_stable (a, tol, disc) |
|
51 |
|
52 if( (nargin < 1) | (nargin > 3) ) usage("is_stable(a {,tol,disc})"); |
4030
|
53 elseif(isstruct(a)) |
3441
|
54 ## system was passed |
|
55 if(nargin < 3) disc = is_digital(a); |
|
56 elseif(disc != is_digital(a)) |
|
57 warning("is_stable: disc =%d does not match system",disc) |
|
58 endif |
|
59 sys = sysupdate(a,"ss"); |
|
60 a = sys2ss(sys); |
|
61 else |
|
62 if(nargin < 3) disc = 0; endif |
4030
|
63 if(issquare(a) == 0) |
3441
|
64 error("A(%dx%d) must be square",rows(A), columns(A)); |
|
65 endif |
|
66 endif |
|
67 |
|
68 if(nargin < 2) tol = 200*eps; |
4030
|
69 elseif( !isscalar(tol) ) |
3441
|
70 error("is_stable: tol(%dx%d) must be a scalar",rows(tol),columns(tol)); |
|
71 endif |
|
72 |
|
73 l = eig(a); |
|
74 if(disc) nbad = sum(abs(l)*(1+tol) > 1); |
|
75 else nbad = sum(real(l)+tol > 0); endif |
|
76 retval = (nbad == 0); |
|
77 |
|
78 endfunction |