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 |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
3500
|
20 ## @deftypefn {Function File} {} is_stable (@var{a}, @var{tol}, @var{dflg}) |
|
21 ## @deftypefnx {Function File} {} is_stable (@var{sys}, @var{tol}) |
|
22 ## Returns 1 if the matrix @var{a} or the system @var{sys} |
3441
|
23 ## is stable, or 0 if not. |
|
24 ## |
|
25 ## @strong{Inputs} |
|
26 ## @table @var |
|
27 ## @item tol |
|
28 ## is a roundoff paramter, set to 200*@var{eps} if omitted. |
|
29 ## @item dflg |
|
30 ## Digital system flag (not required for system data structure): |
|
31 ## @table @code |
|
32 ## @item @var{dflg} != 0 |
|
33 ## stable if eig(a) in unit circle |
|
34 ## |
|
35 ## @item @var{dflg} == 0 |
|
36 ## stable if eig(a) in open LHP (default) |
|
37 ## @end table |
|
38 ## @end table |
|
39 ## @end deftypefn |
|
40 ## @seealso{size, rows, columns, length, is_matrix, is_scalar, is_vector |
|
41 ## is_observable, is_stabilizable, is_detectable, krylov, and krylovb} |
|
42 |
|
43 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
44 ## Created: August 1993 |
|
45 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for systems |
|
46 ## Updated to simpler form by a.s.hodel 1998 |
|
47 |
|
48 function retval = is_stable (a, tol, disc) |
|
49 |
|
50 if( (nargin < 1) | (nargin > 3) ) usage("is_stable(a {,tol,disc})"); |
|
51 elseif(is_struct(a)) |
|
52 ## system was passed |
|
53 if(nargin < 3) disc = is_digital(a); |
|
54 elseif(disc != is_digital(a)) |
|
55 warning("is_stable: disc =%d does not match system",disc) |
|
56 endif |
|
57 sys = sysupdate(a,"ss"); |
|
58 a = sys2ss(sys); |
|
59 else |
|
60 if(nargin < 3) disc = 0; endif |
|
61 if(is_square(a) == 0) |
|
62 error("A(%dx%d) must be square",rows(A), columns(A)); |
|
63 endif |
|
64 endif |
|
65 |
|
66 if(nargin < 2) tol = 200*eps; |
|
67 elseif( !is_scalar(tol) ) |
|
68 error("is_stable: tol(%dx%d) must be a scalar",rows(tol),columns(tol)); |
|
69 endif |
|
70 |
|
71 l = eig(a); |
|
72 if(disc) nbad = sum(abs(l)*(1+tol) > 1); |
|
73 else nbad = sum(real(l)+tol > 0); endif |
|
74 retval = (nbad == 0); |
|
75 |
|
76 endfunction |