3432
|
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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
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 |
|
33 if((nargin < 1) || (nargin > 2) || (nargout > 1)) |
|
34 usage("[gm, ok] = dcgain(sys[, tol])"); |
|
35 endif |
4030
|
36 if(!isstruct(sys)) |
3432
|
37 error("dcgain: first argument is not a system data structure.") |
|
38 endif |
|
39 sys = sysupdate(sys, "ss"); |
|
40 [aa,bb,cc,dd] = sys2ss(sys); |
|
41 if (is_digital(sys)) aa = aa - eye(size(aa)); endif |
|
42 if (nargin == 1) tol = 1.0e-10; endif |
|
43 r = rank(aa, tol); |
|
44 if (r < rows(aa)) |
|
45 gm = []; |
|
46 else |
|
47 gm = -cc / aa * bb + dd; |
|
48 endif |
|
49 if(!is_stable(sys)) |
|
50 [nn,nz,mm,pp] = sysdimensions(sys); |
|
51 warning("dcgain: unstable system; dimensions [nc=%d,nz=%d,mm=%d,pp=%d]", ... |
|
52 nn,nz,mm,pp); |
|
53 endif |
|
54 |
|
55 endfunction |