7017
|
1 ## Copyright (C) 1996, 2000, 2002, 2003, 2004, 2005, 2006, 2007 |
|
2 ## Auburn University. All rights reserved. |
3430
|
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. |
3430
|
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. |
3430
|
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/>. |
3430
|
19 |
|
20 ## -*- texinfo -*- |
3502
|
21 ## @deftypefn {Function File} {[@var{dsys}, @var{adc}, @var{cdc}] =} sysdisc (@var{sys}) |
3430
|
22 ## |
5016
|
23 ## @strong{Input} |
|
24 ## @table @var |
|
25 ## @item sys |
|
26 ## System data structure. |
|
27 ## @end table |
3430
|
28 ## |
|
29 ## @strong{Outputs} |
|
30 ## @table @var |
|
31 ## @item dsys |
5016
|
32 ## Purely discrete portion of sys (returned empty if there is |
|
33 ## no purely discrete path from inputs to outputs). |
3502
|
34 ## @item adc |
|
35 ## @itemx cdc |
7001
|
36 ## Connections from continuous states to discrete states and discrete |
3430
|
37 ## outputs, respectively. |
|
38 ## @end table |
|
39 ## @end deftypefn |
|
40 |
|
41 function [dsys, Adc, Cdc] = sysdisc (sys) |
|
42 |
5568
|
43 if (nargin != 1) |
6046
|
44 print_usage (); |
5568
|
45 elseif (!isstruct(sys)) |
|
46 error("sys must be in system data structure form"); |
|
47 endif |
3430
|
48 |
5568
|
49 sys = sysupdate (sys, "ss"); |
|
50 [n_tot, st_c, st_d, y_c, y_d] = __syscont_disc__ (sys); # get ranges |
3430
|
51 |
5568
|
52 ## assume there's nothing there; build partitions as appropriate |
|
53 Add = Adc = Bdd = Cdd = Cdc = Ddd = []; |
3430
|
54 |
5568
|
55 if(isempty(st_d) & isempty(y_d)) |
7001
|
56 error("sysdisc: expecting discrete states and/or continuous outputs"); |
5568
|
57 elseif (isempty(st_d)) |
|
58 warning("sysdisc: no discrete states"); |
|
59 elseif(isempty(y_d)) |
|
60 warning("sysdisc: no discrete outputs"); |
|
61 endif |
3430
|
62 |
5568
|
63 [aa,bb,cc,dd] = sys2ss(sys); |
|
64 if(!isempty(st_d) ) |
|
65 Add = aa( st_d , st_d); |
|
66 stname = sysgetsignals(sys,"st",st_d); |
|
67 Bdd = bb( st_d , :); |
|
68 if(!isempty(st_c)) |
4460
|
69 Adc = aa( st_d , st_c); |
3430
|
70 endif |
|
71 if(!isempty(y_d)) |
5568
|
72 Cdd = cc(y_d , st_d); |
|
73 endif |
|
74 else |
|
75 stname = []; |
|
76 endif |
|
77 if(!isempty(y_d)) |
|
78 Ddd = dd(y_d , :); |
|
79 outname = sysgetsignals(sys,"out",y_d); |
|
80 if(!isempty(st_c)) |
4460
|
81 Cdc = cc(y_d , st_c); |
3430
|
82 endif |
5568
|
83 else |
|
84 outname=[]; |
|
85 endif |
|
86 inname = sysgetsignals(sys,"in"); |
|
87 outlist = 1:rows(outname); |
3430
|
88 |
5568
|
89 if(!isempty(outname)) |
|
90 tsam = sysgettsam(sys); |
|
91 [nc,nz] = sysdimensions(sys); |
|
92 dsys = ss(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); |
|
93 else |
|
94 dsys=[]; |
|
95 endif |
3430
|
96 |
|
97 endfunction |