3431
|
1 ## Copyright (C) 1996, 1999 Auburn University. All rights reserved. |
|
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, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
3500
|
20 ## @deftypefn {Function File} {} is_digital (@var{sys}) |
3431
|
21 ## Return nonzero if system is digital; |
|
22 ## inputs: |
|
23 ## sys: system data structure |
|
24 ## eflg: 0 [default] exit with an error if system is mixed (continuous and |
|
25 ## discrete components) |
|
26 ## : 1 print a warning if system is mixed (continuous and discrete) |
|
27 ## : 2 silent operation |
|
28 ## outputs: |
|
29 ## DIGITAL: 0: system is purely continuous |
|
30 ## : 1: system is purely discrete |
|
31 ## : -1: system is mixed continuous and discrete |
|
32 ## Exits with an error of sys is a mixed (continuous and discrete) system |
|
33 ## @end deftypefn |
|
34 |
|
35 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
36 ## Created: July 1996 |
|
37 |
|
38 function DIGITAL = is_digital (sys, eflg) |
|
39 |
|
40 switch(nargin) |
|
41 case(1), eflg = 0; |
|
42 case(2), |
|
43 if( isempty(find(eflg == [0, 1, 2])) ) |
|
44 error("invalid value of eflg=%d (%e)",eflg,eflg); |
|
45 endif |
|
46 otherwise, |
|
47 usage("DIGITAL = is_digital(sys{,eflg})"); |
|
48 endswitch |
|
49 |
|
50 ## checked for sampled data system (mixed) |
|
51 ## discrete system |
|
52 sysyd = sysgetsignals(sys,"yd"); |
|
53 [nn,nz] = sysdimensions(sys); |
|
54 cont = sum(sysyd == 0) + nn; |
|
55 tsam = sysgettsam(sys); |
|
56 dig = sum(sysyd != 0) + nz + tsam; |
|
57 |
|
58 ## check for mixed system |
|
59 if( cont*dig != 0) |
|
60 switch(eflg) |
|
61 case(0), |
|
62 error("continuous/discrete system; use syscont, sysdisc, or c2d first"); |
|
63 case(1), |
|
64 warning("is_digital: mixed continuous/discrete system"); |
|
65 endswitch |
|
66 dig_sign = -1; |
|
67 else |
|
68 dig_sign = 1; |
|
69 endif |
|
70 |
|
71 DIGITAL = dig_sign*(tsam > 0); |
|
72 |
|
73 endfunction |