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 |
7136
|
50 switch (nargin) |
|
51 case 1 |
|
52 eflg = 0; |
|
53 case 2 |
|
54 if (isempty (find (eflg == [0, 1, 2]))) |
|
55 error ("invalid value of eflg=%g", eflg); |
3431
|
56 endif |
|
57 otherwise, |
6046
|
58 print_usage (); |
3431
|
59 endswitch |
|
60 |
|
61 ## checked for sampled data system (mixed) |
|
62 ## discrete system |
7136
|
63 sysyd = sysgetsignals (sys, "yd"); |
|
64 [nn, nz] = sysdimensions (sys); |
|
65 cont = sum (sysyd == 0) + nn; |
|
66 tsam = sysgettsam (sys); |
|
67 dig = sum (sysyd != 0) + nz + tsam; |
3431
|
68 |
|
69 ## check for mixed system |
7136
|
70 if (cont*dig != 0) |
|
71 switch (eflg) |
|
72 case 0 |
|
73 error ("continuous/discrete system; use syscont, sysdisc, or c2d first"); |
|
74 case 1 |
|
75 warning ("is_digital: mixed continuous/discrete system"); |
3431
|
76 endswitch |
|
77 dig_sign = -1; |
|
78 else |
|
79 dig_sign = 1; |
|
80 endif |
|
81 |
|
82 DIGITAL = dig_sign*(tsam > 0); |
|
83 |
|
84 endfunction |