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