annotate scripts/control/base/dcgain.m @ 7498:a939fb03a137

pkg.m style fixes
author John W. Eaton <jwe@octave.org>
date Tue, 19 Feb 2008 19:25:19 -0500
parents 1d0d7be2d0f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 1993, 1994, 1995, 2000, 2002, 2004, 2005, 2006, 2007
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
2 ## John W. Eaton
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
3 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
4 ## This file is part of Octave.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
5 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
9 ## your option) any later version.
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
10 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
14 ## General Public License for more details.
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
15 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
18 ## <http://www.gnu.org/licenses/>.
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
19
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
3502
b5238ac1dca9 [project @ 2000-01-31 07:40:53 by jwe]
jwe
parents: 3500
diff changeset
21 ## @deftypefn {Function File} {} dcgain (@var{sys}, @var{tol})
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
22 ## Returns dc-gain matrix. If dc-gain is infinite
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
23 ## an empty matrix is returned.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
24 ## The argument @var{tol} is an optional tolerance for the condition
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4030
diff changeset
25 ## number of the @math{A} Matrix in @var{sys} (default @var{tol} = 1.0e-10)
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
26 ## @end deftypefn
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
27
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
28 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de>
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
29 ## Created: October 1, 1997
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
30
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
31 function gm = dcgain (sys, tol)
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
32
7133
1d0d7be2d0f8 [project @ 2007-11-08 16:25:44 by jwe]
jwe
parents: 7126
diff changeset
33 if (nargin < 1 || nargin > 2)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5307
diff changeset
34 print_usage ();
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
35 endif
7126
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
36 if (! isstruct (sys))
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
37 error ("dcgain: first argument is not a system data structure.")
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
38 endif
7126
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
39 sys = sysupdate (sys, "ss");
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
40 [aa, bb, cc, dd] = sys2ss (sys);
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
41 if (is_digital (sys))
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
42 aa = aa - eye (size (aa));
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
43 endif
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
44 if (nargin == 1)
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
45 tol = 1.0e-10;
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
46 endif
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
47 r = rank (aa, tol);
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
48 if (r < rows (aa))
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
49 gm = [];
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
50 else
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
51 gm = -cc / aa * bb + dd;
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
52 endif
7126
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
53 if (! is_stable (sys))
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
54 [nn, nz, mm, pp] = sysdimensions (sys);
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
55 warning ("dcgain: unstable system; dimensions: nc=%d, nz=%d, mm=%d, pp=%d",
4a375de63f66 [project @ 2007-11-08 03:44:14 by jwe]
jwe
parents: 7017
diff changeset
56 nn, nz, mm, pp);
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
57 endif
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
58
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
59 endfunction