annotate scripts/control/system/is_stable.m @ 3975:1339486fb498

[project @ 2002-07-04 17:42:59 by jwe]
author jwe
date Thu, 04 Jul 2002 17:43:00 +0000
parents 7923abdeb4e5
children 22bd65326ec1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1993, 1994, 1995 Auburn University. All rights reserved.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
2 ##
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
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by the
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
8 ## later version.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
9 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
13 ## for more details.
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
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
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 -*-
3500
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3441
diff changeset
20 ## @deftypefn {Function File} {} is_stable (@var{a}, @var{tol}, @var{dflg})
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3441
diff changeset
21 ## @deftypefnx {Function File} {} is_stable (@var{sys}, @var{tol})
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3441
diff changeset
22 ## Returns 1 if the matrix @var{a} or the system @var{sys}
3441
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
23 ## is stable, or 0 if not.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
24 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
25 ## @strong{Inputs}
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
26 ## @table @var
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
27 ## @item tol
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
28 ## is a roundoff paramter, set to 200*@var{eps} if omitted.
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
29 ## @item dflg
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
30 ## Digital system flag (not required for system data structure):
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
31 ## @table @code
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
32 ## @item @var{dflg} != 0
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
33 ## stable if eig(a) in unit circle
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
34 ##
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
35 ## @item @var{dflg} == 0
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
36 ## stable if eig(a) in open LHP (default)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
37 ## @end table
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
38 ## @end table
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
39 ## @end deftypefn
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
40 ## @seealso{size, rows, columns, length, is_matrix, is_scalar, is_vector
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
41 ## is_observable, is_stabilizable, is_detectable, krylov, and krylovb}
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
42
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
43 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu>
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
44 ## Created: August 1993
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
45 ## Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for systems
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
46 ## Updated to simpler form by a.s.hodel 1998
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
47
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
48 function retval = is_stable (a, tol, disc)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
49
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
50 if( (nargin < 1) | (nargin > 3) ) usage("is_stable(a {,tol,disc})");
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
51 elseif(is_struct(a))
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
52 ## system was passed
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
53 if(nargin < 3) disc = is_digital(a);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
54 elseif(disc != is_digital(a))
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
55 warning("is_stable: disc =%d does not match system",disc)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
56 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
57 sys = sysupdate(a,"ss");
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
58 a = sys2ss(sys);
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 if(nargin < 3) disc = 0; endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
61 if(is_square(a) == 0)
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
62 error("A(%dx%d) must be square",rows(A), columns(A));
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
63 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
64 endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
65
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
66 if(nargin < 2) tol = 200*eps;
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
67 elseif( !is_scalar(tol) )
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
68 error("is_stable: tol(%dx%d) must be a scalar",rows(tol),columns(tol));
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
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
71 l = eig(a);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
72 if(disc) nbad = sum(abs(l)*(1+tol) > 1);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
73 else nbad = sum(real(l)+tol > 0); endif
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
74 retval = (nbad == 0);
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
75
36ae9880c594 [project @ 2000-01-14 22:03:32 by jwe]
jwe
parents:
diff changeset
76 endfunction