7017
|
1 ## Copyright (C) 1996, 1999, 2000, 2004, 2005, 2006, 2007 |
|
2 ## Auburn University. All rights reserved. |
3431
|
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. |
3431
|
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. |
3431
|
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/>. |
3431
|
19 |
|
20 ## -*- texinfo -*- |
5016
|
21 ## @deftypefn {Function File} {@var{digital} =} is_digital (@var{sys}, @var{eflg}) |
|
22 ## Return nonzero if system is digital. |
|
23 ## |
|
24 ## @strong{Inputs} |
|
25 ## @table @var |
|
26 ## @item sys |
|
27 ## System data structure. |
|
28 ## @item eflg |
|
29 ## When equal to 0 (default value), exits with an error if the system |
|
30 ## is mixed (continuous and discrete components); when equal to 1, print |
|
31 ## a warning if the system is mixed (continuous and discrete); when equal |
|
32 ## to 2, operate silently. |
|
33 ## @end table |
|
34 ## |
|
35 ## @strong{Output} |
|
36 ## @table @var |
|
37 ## @item digital |
|
38 ## When equal to 0, the system is purely continuous; when equal to 1, the |
|
39 ## system is purely discrete; when equal to -1, the system is mixed continuous |
|
40 ## and discrete. |
|
41 ## @end table |
|
42 ## Exits with an error if @var{sys} is a mixed (continuous and discrete) system. |
3431
|
43 ## @end deftypefn |
|
44 |
|
45 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
46 ## Created: July 1996 |
|
47 |
|
48 function DIGITAL = is_digital (sys, eflg) |
|
49 |
|
50 switch(nargin) |
|
51 case(1), eflg = 0; |
|
52 case(2), |
|
53 if( isempty(find(eflg == [0, 1, 2])) ) |
|
54 error("invalid value of eflg=%d (%e)",eflg,eflg); |
|
55 endif |
|
56 otherwise, |
6046
|
57 print_usage (); |
3431
|
58 endswitch |
|
59 |
|
60 ## checked for sampled data system (mixed) |
|
61 ## discrete system |
|
62 sysyd = sysgetsignals(sys,"yd"); |
|
63 [nn,nz] = sysdimensions(sys); |
|
64 cont = sum(sysyd == 0) + nn; |
|
65 tsam = sysgettsam(sys); |
|
66 dig = sum(sysyd != 0) + nz + tsam; |
|
67 |
|
68 ## check for mixed system |
|
69 if( cont*dig != 0) |
|
70 switch(eflg) |
|
71 case(0), |
|
72 error("continuous/discrete system; use syscont, sysdisc, or c2d first"); |
|
73 case(1), |
|
74 warning("is_digital: mixed continuous/discrete system"); |
|
75 endswitch |
|
76 dig_sign = -1; |
|
77 else |
|
78 dig_sign = 1; |
|
79 endif |
|
80 |
|
81 DIGITAL = dig_sign*(tsam > 0); |
|
82 |
|
83 endfunction |