3213
|
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton |
|
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, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
18 |
|
19 function gm = dcgain(sys, tol) |
|
20 # Usage: gm = dcgain(sys[, tol]) |
|
21 # Returns dc-gain matrix. If dc-gain is infinity |
|
22 # an empty matrix is returned. |
|
23 # The argument tol is an optional tolerance for the condition |
|
24 # number of A-Matrix in sys (default tol = 1.0e-10) |
3228
|
25 # Prints a warning message of the system is unstable. |
3213
|
26 # |
|
27 |
|
28 # Written by Kai P Mueller (mueller@ifr.ing.tu-bs.de) October 1, 1997 |
3228
|
29 # $Revision: 2.0.0.0 $ |
3213
|
30 |
|
31 if((nargin < 1) || (nargin > 2) || (nargout > 1)) |
|
32 usage("[gm, ok] = dcgain(sys[, tol])"); |
|
33 endif |
|
34 if(!is_struct(sys)) |
|
35 error("dcgain: first argument is not a system data structure.") |
|
36 endif |
|
37 sys = sysupdate(sys, "ss"); |
3228
|
38 [aa,bb,cc,dd] = sys2ss(sys); |
3213
|
39 if (is_digital(sys)) aa = aa - eye(size(aa)); endif |
|
40 if (nargin == 1) tol = 1.0e-10; endif |
|
41 r = rank(aa, tol); |
|
42 if (r < rows(aa)) |
|
43 gm = []; |
|
44 else |
3228
|
45 gm = -cc / aa * bb + dd; |
|
46 endif |
|
47 if(!is_stable(sys)) |
|
48 [nn,nz,mm,pp] = sysdimensions(sys); |
|
49 warning("dcgain: unstable system; dimensions [nc=%d,nz=%d,mm=%d,pp=%d]", ... |
|
50 nn,nz,mm,pp); |
3213
|
51 endif |
|
52 endfunction |