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